[fpc-pascal] Console Encoding in Windows (Local VS. UTF8)
jonas.maebe at elis.ugent.be
Tue Jul 9 11:13:53 CEST 2013
On 09 Jul 2013, at 11:02, Noah Silva wrote:
> 1. What encoding "should" I be writing to the terminal?
The console code page. You can get it using the following function:
function GetConsoleOutputCP : UINT; stdcall; external 'kernel32'
> from experimenting
> with text files using the cat command in powershell, it seems that
> ("ANSI") encoding should be used. This makes sense since older
> versions of
> windows only supported local encodings.
The ansi code page is (or at least can be) different, that's the the
function GetACP:UINT; stdcall; external 'kernel32' name 'GetACP';
> 2. Is there any reason why writing out data in the local encoding
> write statements, etc.) should get corrupted? For example is some
> level of
> the RTL assuming something about the encoding? (I don't think so,
Not in 2.6.x. In 2.7.x, every ansistring is tagged with a code page
(the ansi code page by default) and the RTL will convert it to the
console code page before writing it.
> 3. Is there a way to set the output to UTF8 so I can just write out
> and be done with it?
I don't know.
More information about the fpc-pascal