Page 1 of 1
reading/displaying UTF-8 TXT file
Posted: Tue Nov 10, 2020 4:01 pm
by serge_girard
Hello,
I need to upload some data from a text-file (saved as UTF-8) containing: ë, ç, à, á, â,ã,ä,å,æ,ç,è.. etc...
Reading this file and displaying the content in another file is no problem, but displaying on screen gives
something like this: Préporché instead of Préporché.
So my input file contains "Préporché", writing to new file is OK but displaying on the screen is not.
How to fix this problem?
Serge
Re: reading/displaying UTF-8 TXT file
Posted: Tue Nov 10, 2020 6:28 pm
by SvargasD
Hola Serge:
Hace tiempo tuve el problema al revés, mi archivo de texto generaba caracteres extraños al guardar. Lo solucione con ayuda de este foro donde recurrí al juego de caracteres que puedes configurar en cada programa que generas.
REQUEST HB_CODEPAGE_ESWIN
HB_SETCODEPAGE("ESWIN")
REQUEST HB_LANG_ES
HB_LANGSELECT( "ES" )
SET LANGUAGE TO SPANISH
Por el error que mencionas, me parece que el problema esta con la configuración de idiomas del sistema operativo que ejecutas, talvez si revisas la configuración regional y de idiomas de Windows podrías solucionarlo.
Re: reading/displaying UTF-8 TXT file
Posted: Tue Nov 10, 2020 8:13 pm
by serge_girard
Hi SvargasD,
Thanks, but it doesn't work....
Serge
Re: reading/displaying UTF-8 TXT file
Posted: Tue Nov 10, 2020 8:33 pm
by jparada
Hi,
I have just that drawback and it actually has to do with the OS codepage and even the codepage of the editor with which you write your code.
When the problem is just as you mentioned about displaying on the screen, I personally solve it with hb_Utf8ToStr, since my code editor is set to UTF-8 and my Windows codepage is different.
Hope it helps you.
Regards,
Javier
Re: reading/displaying UTF-8 TXT file
Posted: Wed Nov 11, 2020 8:26 am
by serge_girard
Javier,
Thanks this has brought me to the solution:
Code: Select all
REQUEST HB_CODEPAGE_FRWIN
hb_setcodepage("FRWIN")
//then:
IF hb_StrIsUTF8(cSTR)
cSTR := hb_utf8tostr(cSTR, 'FRWIN')
ENDIF
// this is the correct translation !!
Thanks again !
Serge