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

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Dec 3 15:26:26 CET 2015


Lubos Pintes wrote on Thu, 03 Dec 2015:

> 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



More information about the fpc-pascal mailing list