[fpc-pascal] Console Encoding in Windows (Local VS. UTF8)
Noah Silva
shiruba at galapagossoftware.com
Mon Jul 29 04:44:11 CEST 2013
Hi,
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';
>
>
>
This is 932 on my system, as expected.
http://msdn.microsoft.com/ja-JP/goglobal/cc305152.aspx
> 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';
>
> This is also 932, as expected.
(I assume they should always be the same though, I don't think most
programs check the console output page before writing).
> 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.
>
> And I am using 2.6, so it should be clean, yet somehow it's not working
out that way. I think I will have to debut writeln...
> Jonas
>
> Thank you,
Noah Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130729/f232d311/attachment.html>
More information about the fpc-pascal
mailing list