UTF8 to ANSI (or to OEM)

1,757 views
Skip to first unread message

Qatan

unread,
Oct 31, 2010, 8:50:58 PM10/31/10
to harbou...@googlegroups.com
Hello,
 
    Does anyone has a working example of such string conversion?
    I prepared a self contained example of what I want to do but somehow I got strange results, maybe I missed something.
    Please download and try yourself: hbmk2 test -run
    Thanks for any hint.
    Regards,
 
Qatan
 
 

Massimo Belgrano

unread,
Nov 1, 2010, 7:48:24 AM11/1/10
to harbou...@googlegroups.com
Thanks for your sample
what is strange for you?

procedure main()

local cStr := hb_utf8tostr( hb_memoread( 'utf8.txt' ) )

setmode(40,80);setcolor('w+/n');cls

? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OEMtoANSI + UTF8toSTR: ',hb_oemtoansi( hb_utf8tostr( cStr ) )
? 'ANSItoOEM + UTF8toSTR: ',hb_ansitooem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OEMtoANSI: ',hb_utf8tostr( hb_oemtoansi( cStr ) )
? 'UTF8toSTR + ANSItoOEM: ',hb_utf8tostr( hb_ansitooem( cStr ) )
? 'OEMtoANSI : ',hb_oemtoansi( cStr )
? 'ANSItoOEM : ',hb_ansitooem( cStr )
?

cStr := hb_utf8tostr( memoread( 'utf8.txt' ) )

? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OEMtoANSI + UTF8toSTR: ',hb_oemtoansi( hb_utf8tostr( cStr ) )
? 'ANSItoOEM + UTF8toSTR: ',hb_ansitooem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OEMtoANSI: ',hb_utf8tostr( hb_oemtoansi( cStr ) )
? 'UTF8toSTR + ANSItoOEM: ',hb_utf8tostr( hb_ansitooem( cStr ) )
? 'OEMtoANSI : ',hb_oemtoansi( cStr )
? 'ANSItoOEM : ',hb_ansitooem( cStr )
?
cStr := hb_memoread( 'utf8.txt' )

? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OEMtoANSI + UTF8toSTR: ',hb_oemtoansi( hb_utf8tostr( cStr ) )
? 'ANSItoOEM + UTF8toSTR: ',hb_ansitooem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OEMtoANSI: ',hb_utf8tostr( hb_oemtoansi( cStr ) )
? 'UTF8toSTR + ANSItoOEM: ',hb_utf8tostr( hb_ansitooem( cStr ) )
? 'OEMtoANSI : ',hb_oemtoansi( cStr )
? 'ANSItoOEM : ',hb_ansitooem( cStr )
?
cStr := memoread( 'utf8.txt' )
? 'Directly : ', cStr
? 'UTF8toSTR : ',hb_utf8tostr( cStr )
? 'OEMtoANSI + UTF8toSTR: ',hb_oemtoansi( hb_utf8tostr( cStr ) )
? 'ANSItoOEM + UTF8toSTR: ',hb_ansitooem( hb_utf8tostr( cStr ) )
? 'UTF8toSTR + OEMtoANSI: ',hb_utf8tostr( hb_oemtoansi( cStr ) )
? 'UTF8toSTR + ANSItoOEM: ',hb_utf8tostr( hb_ansitooem( cStr ) )
? 'OEMtoANSI : ',hb_oemtoansi( cStr )
? 'ANSItoOEM : ',hb_ansitooem( cStr )
?

wait
return


**utf.txt
(aeiou) x (áúíóãõ) x (áéíú)

2010/11/1 Qatan <wanst...@gmail.com>:

> --
> You received this message because you are subscribed to the Google
> Groups "Harbour Users" group.
> Unsubscribe: harbour-user...@googlegroups.com
> Web: http://groups.google.com/group/harbour-users
>

--
Massimo Belgrano

Iscritto all'albo dei CTU presso il Tribunale di Novara per materia Informatica
Delta Informatica S.r.l. (http://www.deltain.it/) (+39 0321 455962)
Analisi e sviluppo software per Lan e Web -  Consulenza informatica - Formazione

Massimo Belgrano

unread,
Nov 1, 2010, 8:04:09 AM11/1/10
to Harbour Users

Qatan

unread,
Nov 1, 2010, 9:20:22 AM11/1/10
to harbou...@googlegroups.com
Hello Massimo,

>Thanks for your sample
>what is strange for you?

The result on SCREEN is DIFFERENT from what you see on the TXT file.
The TXT was created and saved using Windows Notepad in UTF8 format.

Thanks for your help.

Qatan

PS: See the screen: http://www.tribaltradingcompany.com.br/qatan/Image.jpg

Qatan

unread,
Nov 1, 2010, 1:49:30 PM11/1/10
to harbou...@googlegroups.com
Hello Massimo,

The best result I found was:

[CODE]
procedure main()
local cStr := ( hb_memoread( 'utf8.txt' ) )
setmode(25,80);setcolor('w+/n');cls
? 'Directly : ',cStr
? 'UTF8toSTR OEM : ',hb_utf8tostr( cStr )
? 'UTF8toSTR ANSI: ',hb_oemtoansi( hb_utf8tostr( cStr ) )
?
wait
return
[/CODE]

But special chars "�" and "� "do not show correct in this test
Do you know why? What am I missing here?
Thanks for any help.

Qatan

http://harbourlanguage.blogspot.com/search/label/codepage

--

Reply all
Reply to author
Forward
0 new messages