| |
|
|
| Ragnar Rehbein
Thread: [...] Have me today too straight with UTF-8 bait must. I needed a Conversion of ANSI To UTF-8. The Längenbestimmung the resultierenden Strings has first not so functions How expects, therefore The something umständlich erscheinende method with the detach the NULL-Bytes. CompileMarkSeparation $H windows.ph
{$cleq}
proc AnsiToUTF8
parameters ansistring$
declare unicode$, utf8$, laenge&
laenge& = len(ansistring$)*2
unicode$ = mkstr$(chr$(0),laenge&)
~MultiByteToWideChar(~CP_ACP,0,Addr(ansistring$),-1,addr(unicode$),laenge&)
laenge& = ~WideCharToMultiByte(~CP_UTF8,0,Addr(unicode$),-1,0,0,0,0)
UTF8$ = mkstr$(chr$(0),laenge&)
~WideCharToMultiByte(~CP_UTF8,0,Addr(unicode$),len(unicode$),Addr(UTF8$),laenge&,0,0)
utf8$ = substr$(utf8$,1,chr$(0))
return utf8$
endproc
proc UTF8ToAnsi
parameters utf8$
declare ansistring$, unicode$, laenge&
laenge& = len(utf8$) * 2
unicode$ = mkstr$(chr$(0),laenge&)
~MultiByteToWideChar(~CP_UTF8,0,Addr(utf8$),-1,Addr(unicode$),laenge&)
ansistring$ = mkstr$(chr$(0),laenge&)
~WideCharToMultiByte(~CP_ACP,0,Addr(unicode$),-1,Addr(ansistring$),laenge&,0,0)
ansistring$ = substr$(ansistring$,1,chr$(0))
return ansistring$
endproc
cls
declare x$
x$ = ansiToUTF8(Rön Réne)
print x$
writeini c:utf8.txt,code,utf8code=x$
x$ = UTF8ToAnsi(x$)
print x$
writeini c:utf8.txt,code,ansicode=x$
waitinput
Greeting Ragnar |
|
|
| |
|
|