Page 1 of 1
unicode (no not again! :-))
Posted: Sat May 15, 2004 5:17 pm
by blueznl
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: Select all
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
Posted: Sat May 15, 2004 5:26 pm
by fweil
Should make you more happy I guess ...
Code: Select all
;
; 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)
Posted: Sat May 15, 2004 5:30 pm
by blueznl
cannot store a unicode string in a normal string?
Posted: Sat May 15, 2004 6:50 pm
by blueznl
duh... oh...
swapped the functions
Code: Select all
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
Posted: Sat May 15, 2004 7:20 pm
by fweil
... was away for a while ! Hem it's saturday you know ...

Posted: Sun May 16, 2004 5:59 pm
by Rings
blueznl wrote:cannot store a unicode string in a normal string?
can contain NULL's, so better use Memory for now
Posted: Sun May 16, 2004 6:07 pm
by blueznl
yeah, after some messing around i finally understood... i want my fixed length strings... oh wait, have to control my whining until fred returns
