[fpc-devel] " crt garbles writeln() output " feedback: other problems; not crt specific; command line parameters

ϸ�� ����������� � mail.ru ppkk at mail.ru
Tue May 23 22:27:35 CEST 2006


>> However (as Maxim Ganetsky, who invented the patch, noted) the
>> windows console is a mess.
pg> It is indeed. Windows uses the ANSI code page for most GUI stuff but uses
pg> the OEM code page for the console (at least by default i belive there may be
pg> ways to change it). In MOST cases the ANSI and OEM code pages are
pg> significantly different!

And the patch used system functions to know, which codepage to use.

My message was just a report about uncovered features.
("crt garbles writeln() output" bug was higher priority: it concerned TP
compatibility.)

pg> {ansi|short}string <-> widestring conversion is not really possible to do
pg> right automatically. The compiler simply can't know what character set the
pg> {ansi|short}string is meant to represent! It defaults to ISO-8859-1 (aka
pg> direct code value mapping) which at least provides round trip compatibility
pg> but apps that care are strongly advised to either register thier own
pg> conversion functions or avoid automatic ansistring <-> widestring
pg> conversions.

It's easy: (just like Maxim wrote)
function w2a(const widestring; var ansistring; target_encoding: integer or something): integer;
 --- for utf16
function w2a(const widestring; var ansistring; source_encoding: ...; target_encoding: ...): integer;
 --- for EBCDIC etc

(output for success/fail result and various info, like first
unconvertible symbol, number of converted symbols etc; some errors may
be reacted by exceptions: not enough length etc)
 
And, finally, typecast: widestring->ansistring, assuming utf16 and
GetConsoleOutputCP() (or something else on other platforms/in
non-console modes).

And similar procedures in the opposite direction.

It is matter of priorities: the mappings are long known. Unicode
standard is quite open too. If I had much free time, I'd work on
porting such a thing (from somewhere, there are many places) to FPC.
But I'm not yet accustommed to my full-time job:(




More information about the fpc-devel mailing list