Page 1 of 1

UTF-8 con BOM

Posted: Sun Mar 30, 2025 8:38 pm
by Silvio.Falconi
is there a command or function that can convert all special characters such as "à" or "n°" because when I put it in an html file I see strange symbols, it would take a command like UTF-8 with BOM

on my html I allready insert

Code: Select all | Expand

 TEXT INTO cHtml
      <!DOCTYPE html>
      <html lang="it">
      <head>
         <meta charset="UTF-8">
but it's not enough

because I have a string as "contabilità" with a grave or "Ordine n°" and on html I see a symbol ?

Re: UTF-8 con BOM

Posted: Mon Mar 31, 2025 12:16 am
by cnavarro
You editor is configured for UTF8?

Re: UTF-8 con BOM

Posted: Mon Mar 31, 2025 8:16 pm
by Silvio.Falconi
I use xmate
But the problem Is on a menu "contabilità" i change With che(224) and on the HTML i make a converion. Strtran With agrave;
Now seems tò run ok
For the oders "orders n°' i saw i can change because It Is my script and the Number of invoice come from dbf , i must only make some test

Re: UTF-8 con BOM

Posted: Mon Mar 31, 2025 10:12 pm
by Giovany Vecchi
Try this

Code: Select all | Expand

 TEXT INTO cHtml
_CodeUtf8Bom_
      <!DOCTYPE html>
      <html lang="it">
      <head>
         <meta charset="UTF-8">
ENDTEXT

cHtml := Strtran(cHtml,_CodeUtf8Bom_,chr(239)+chr(187)+chr(191))

Re: UTF-8 con BOM

Posted: Thu Apr 03, 2025 7:19 am
by Silvio.Falconi
´
Giovany Vecchi wrote: Mon Mar 31, 2025 10:12 pm cHtml := Strtran(cHtml,_CodeUtf8Bom_,chr(239)+chr(187)+chr(191))
Error occurred at: 04/03/25, 09:18:56
Error description: Error BASE/1003 Variable does not exist: _CODEUTF8BOM_

Stack Calls
===========
Called from: Source\test.prg => HTML( 95 )
Called from: Source\test.prg => MAIN( 19 )

Re: UTF-8 con BOM

Posted: Thu Apr 03, 2025 9:02 am
by Antonio Linares
Dear Silvio,

Are you using this in your PRG ?

REQUEST HB_CODEPAGE_ITWIN

...

hb_SetCodePage( "ITWIN" )

Re: UTF-8 con BOM

Posted: Thu Apr 03, 2025 6:44 pm
by Giovany Vecchi
Silvio.Falconi wrote: Thu Apr 03, 2025 7:19 am ´
Giovany Vecchi wrote: Mon Mar 31, 2025 10:12 pm cHtml := Strtran(cHtml,_CodeUtf8Bom_,chr(239)+chr(187)+chr(191))
Error occurred at: 04/03/25, 09:18:56
Error description: Error BASE/1003 Variable does not exist: _CODEUTF8BOM_

Stack Calls
===========
Called from: Source\test.prg => HTML( 95 )
Called from: Source\test.prg => MAIN( 19 )
I forgot the quotes

cHtml := Strtran(cHtml,"_CodeUtf8Bom_",chr(239)+chr(187)+chr(191))

Re: UTF-8 con BOM

Posted: Fri Apr 04, 2025 5:28 am
by Carles
Ep!,

Try saving your code from your editor in 'UTF8 WITHOUT BOM' format. If you save code with 'UTF8 WITH BOM', it can cause many such errors in many browsers.

C.