[fpc-pascal] source code UTF8 with BOM problems ?

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Mar 16 12:48:50 CET 2010


On 16 Mar 2010, at 00:59, Luis Fernando Del Aguila Mejía wrote:

> The following source code uses UTF8 without BOM, http://www.conoce3000.com/Ejemplo01.pp
> the compiler compiles ok and the program displays the message in  
> Unicode UTF8 ok
>
> The following source code uses UTF8 with BOM http://www.conoce3000.com/Ejemplo02.pp
> the compiler compiles ok and the program displays the message in  
> Unicode UTF8 with question marks.
>
> How can I tell the compiler to ignore the BOM?

You cannot. Your first program will however only work on terminals  
that are configured to accept UTF-8 output. The correct way is to
a) use the second program (or add {$codepage utf8} at the top of the  
first one)
b) add "uses cwstring;" so that a widestring manager is available,  
which will convert the strings (which are parsed into widestrings) to  
the current session's code page.


Jonas


More information about the fpc-pascal mailing list