Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-12

FPC 3.x for Windows and reading UTF-8 encoded text from standard input

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lubos Pintes

Hi,
How can I read an UTF-8 encoded text under Windows? My Windows locale uses windows-1250 encoding. It seems to me that a conversion to ansi happens when I am reading from standard input, so the UTF-8 text is corrupted.
Do I need to do something special for this to work? Thanks

Reply by email

Jonas Maebe
to Lubos Pintes

Lubos Pintes wrote on Thu, 03 Dec 2015:

Show quoted text 5 lines
How can I read an UTF-8 encoded text under Windows? My Windows locale uses windows-1250 encoding. It seems to me that a conversion to ansi happens when I am reading from standard input, so the UTF-8 text is corrupted. Do I need to do something special for this to work?

By default, reading from standard input indeed results in the RTL interpreting that input according to what the OS says it is. If you want to manually override this, you can use
http://www.freepascal.org/docs-html/rtl/system/settextcodepage.html (for standard read/readln/write/writeln operations). The name of the "text" variable that represents standard input is "Input".

Jonas

Reply by email