English
Source / code snippets

Ansi Utf Utf8

 
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
 
05/19/08  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

4.637 Views

Untitledvor 0 min.
Sven Bader10/14/23
Walter12/22/22
Ju02/16/17
iF01/11/16
More...

Themeninformationen

this Topic has 1 subscriber:

iF (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie