[fpc-pascal] Console Encoding in Windows (Local VS. UTF8)

Noah Silva shiruba at galapagossoftware.com
Sun Jul 14 02:18:42 CEST 2013


Hi,

First, I want thank everyone for taking the time to answer!

2013/7/9 Jonas Maebe <jonas.maebe at elis.ugent.be>

>
> 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' name
> 'GetConsoleOutputCP';
>
> I will certainly check this out.   On the other hand, it seems that on a
Japanese system, it has to either be some form of Unicode or SJIS.  (And it
almost has to be SJIS since older windows versions didn't support Unicode!).

>
>  from experimenting
>> with text files using the cat command in powershell, it seems that local
>> ("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
> result of
>   function GetACP:UINT; stdcall; external 'kernel32' name 'GetACP';
>
>
Again I will check this today, but see above.

>
>  2. Is there any reason why writing out data in the local encoding (with
>> write statements, etc.) should get corrupted?  For example is some level
>> of
>> the RTL assuming something about the encoding? (I don't think so, but...)
>>
>
> 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.


Hmm, so at any rate, I need to support two code paths:
1. Convert it myself if on 2.6
2. Don't convert it if on 2.7

I use UTF8String for everything - I know that it is still just an
ANSIString on FPC - but is the codepage set to UTF8 automatically?

>
>
>  3. Is there a way to set the output to UTF8 so I can just write out UTF8
>> and be done with it?
>>
>
> I don't know.
>
> There is a function to set the output codepage, which someone on this list
told me before.  Unfortunately, it didn't work, and had bad side-effects
(the output window flickers and gets very slow).

>
> Jonas
>

Thank you,
    Noah Silva

> ______________________________**_________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.**org<fpc-pascal at lists.freepascal.org>
> http://lists.freepascal.org/**mailman/listinfo/fpc-pascal<http://lists.freepascal.org/mailman/listinfo/fpc-pascal>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130714/502eecc0/attachment.html>


More information about the fpc-pascal mailing list