It is currently Thu Sep 02, 2010 4:16 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: unicode (no not again! :-))
PostPosted: Sat May 15, 2004 5:17 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat May 17, 2003 11:31 am
Posts: 5204
i am a bit baffled, as i can't seem to get to terms with unicode.. .the following should work, but it doesn't... i guess i'm missing the point somewhere...

Code:
in.s = "dit is een test"
out.s = ""
;
l = WideCharToMultiByte_(#CP_OEMCP,0,@in,-1,0,0,0,0)
out = Space(l)
l = WideCharToMultiByte_(#CP_OEMCP,0,@in,-1,@out,l+1,0,0)
;
Debug l
Debug in.s
Debug out.s
in.s = out.s
;
l = MultiByteToWideChar_(#CP_OEMCP,0,@in,-1,@out,0)
out = Space(l)
l = MultiByteToWideChar_(#CP_OEMCP,0,@in,-1,@out,l)
;
Debug l
Debug in
Debug out

_________________
My ambition in life: Total World Domination! My weapons of choice: CodeCaddy and The PureBasic Survival Guide
( PB4.4x XPpro SP3 Dell XPS710 Intel Q6600 nForce 5 NVidia 8800GTX )


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 15, 2004 5:26 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Apr 22, 2004 5:56 pm
Posts: 718
Location: France
Should make you more happy I guess ...

Code:
;
; UNICODE strings
;
Procedure.l Ansi2Uni(ansi.s)
  size.l=MultiByteToWideChar_(#CP_ACP,0,ansi,-1,0,0)
  Dim unicode.w(size)
  MultiByteToWideChar_(#CP_ACP, 0, ansi, Len(ansi), unicode(), size)
  ProcedureReturn @unicode() 
EndProcedure

Procedure.s Uni2Ansi(*Unicode.l)
  size.l = WideCharToMultiByte_(#CP_ACP, 0, *Unicode, -1, #Null, #Null, #Null, #Null)
  ansi.s=Space(size)
  WideCharToMultiByte_(#CP_ACP, 0, *Unicode, -1, @ansi, size, #Null, #Null)
  ProcedureReturn ansi 
EndProcedure

*pointeur=Ansi2Uni("Ben ça alors, dis donc, si j'avais su.")
Debug Uni2Ansi(*pointeur)

_________________
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 15, 2004 5:30 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat May 17, 2003 11:31 am
Posts: 5204
cannot store a unicode string in a normal string?

_________________
My ambition in life: Total World Domination! My weapons of choice: CodeCaddy and The PureBasic Survival Guide
( PB4.4x XPpro SP3 Dell XPS710 Intel Q6600 nForce 5 NVidia 8800GTX )


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 15, 2004 6:50 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat May 17, 2003 11:31 am
Posts: 5204
duh... oh...

swapped the functions :-)

Code:
in.s = "dit is een test"
;
l = MultiByteToWideChar_(#CP_OEMCP,0,@in,-1,0,0)
*out = AllocateMemory(l)
l = MultiByteToWideChar_(#CP_OEMCP,0,@in,-1,*out,l)
;
*in = *out
;
l = WideCharToMultiByte_(#CP_OEMCP,0,*in,-1,0,0,0,0)
out.s = Space(l)
l = WideCharToMultiByte_(#CP_OEMCP,0,*in,-1,@out,l,0,0)
;
Debug out

_________________
My ambition in life: Total World Domination! My weapons of choice: CodeCaddy and The PureBasic Survival Guide
( PB4.4x XPpro SP3 Dell XPS710 Intel Q6600 nForce 5 NVidia 8800GTX )


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 15, 2004 7:20 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Apr 22, 2004 5:56 pm
Posts: 718
Location: France
... was away for a while ! Hem it's saturday you know ... :oops:

_________________
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2004 5:59 pm 
Offline
Moderator
Moderator
User avatar

Joined: Sat Apr 26, 2003 1:11 am
Posts: 1112
blueznl wrote:
cannot store a unicode string in a normal string?

can contain NULL's, so better use Memory for now

_________________
Thorium wrote:
You don't want to be a script kiddy, do you?


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 16, 2004 6:07 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat May 17, 2003 11:31 am
Posts: 5204
yeah, after some messing around i finally understood... i want my fixed length strings... oh wait, have to control my whining until fred returns :-)

_________________
My ambition in life: Total World Domination! My weapons of choice: CodeCaddy and The PureBasic Survival Guide
( PB4.4x XPpro SP3 Dell XPS710 Intel Q6600 nForce 5 NVidia 8800GTX )


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: TomS and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye