[fpc-pascal] Unicode output on console works for me on Linux, not on Windows
Reinier Olislagers
reinierolislagers at gmail.com
Mon Aug 1 08:09:46 CEST 2011
(Reposted from the forum)
I tried to output Unicode text to console on English Windows Vista
(using Lucida Console font, which shows Greek and Cyrillic characters).
Doesn't seem to work.
(On Debian x64 it works perfectly - maybe because the default encoding
I've got is UTF8: LANG environment variable is en_US.utf8?)
If I redirect the output to file, I can see the output properly for the
output containing "plain" if I open the file as UTF8.
Does anybody know how to do this?
Thanks,
Reinier
{$mode objfpc}{$H+}
program UnicodeTest;
uses
{$IFDEF UNIX}
{$IFDEF UseCThreads}
cthreads,
{$ENDIF}
{Widestring manager needed for widestring support}
cwstring,
{$ENDIF}
Classes,
StrUtils
;
var
UTF8TestString: string;
OurWideString: widestring;
begin
UTF8TestString:= ' rosé, водка and ούζο';
writeln ('plain: ' + UTF8TestString);
writeln (UTF8ToANSI('utf8toansi: ' + UTF8TestString));
writeln (UTF8Decode('utf8decode: ' + UTF8TestString));
//Just for luck, shouldn't work:
writeln (ANSIToUTF8('ansitoutf8: ' + UTF8TestString));
writeln (UTF8Encode('utf8encode: ' + UTF8TestString));
writeln ('');
OurWideString:= 'rosé, водка and ούζο';
writeln ('plain: ' + OurWideString);
writeln (UTF8ToANSI('utf8toansi: ' + OurWideString));
writeln (UTF8Decode('utf8decode: ' + OurWideString));
//Just for luck, shouldn't work:
writeln (UTF8Encode('utf8encode: ' + OurWideString));
writeln (ANSIToUTF8('ansitoutf8: ' + OurWideString));
end.
More information about the fpc-pascal
mailing list