[fpc-pascal] Re: Ido not understand UTF8 in Windows

JoshyFun joshyfun at gmail.com
Fri Feb 19 17:27:12 CET 2010


Hello FPC-Pascal,

Friday, February 19, 2010, 3:22:15 AM, you wrote:

LFDAM> Ok,
LFDAM> The steps are :
LFDAM> 1) Change the Font Type at Lucida Console Font :
LFDAM> http://www.conoce3000.com/fig01.jpg
LFDAM> 2) Compile the program with fpc 2.4. :
LFDAM> 3) change to UTF8, with chcp 65001 command
LFDAM> 4) run the program
LFDAM> Step 01 to 04 : http://www.conoce3000.com/fig02.jpg
LFDAM> The source code : http://www.conoce3000.com/Prueba005.pp
LFDAM> The error ocurred only when use Lucida console Font.

The problem is that by default in Windows stdout is opened in 7 bits
mode (text), this means that writeln when emits some information in
UTF8 with any char >127 will enter in some kind of error reported from
rtl or Windows kernel.

I do not know how to inform the fpc to "reopen" the stdout handle in
binary mode, but you can "hack it" by (at least for tests):

-------------------------
uses classes,windows;

var
 s: string;
 OutputStream: TStream;
Begin
 Writeln('code page UTF8 - 65001 en Windows');
 OutputStream := THandleStream.Create(GetStdHandle(STD_OUTPUT_HANDLE));
 s:='camiĆ³n';
 OutputStream.write(s[1],Length(s));
 OutputStream.free;
End.
-------------------------

-- 
Best regards,
 JoshyFun




More information about the fpc-pascal mailing list