0

My Win10 is setup for Greek codepage, even for programs that don't use Unicode, but the expresion writeln(TextInGreek) prints foreign characters.

Following is a reproducable example:

program Project5;

{$APPTYPE CONSOLE}

var errorMes : string;

begin
    errorMes := 'αβγδεζηθικλμνξοπρστυφχψω';
    writeln(errorMes); // I receive 'άέήϊίόύϋώΆΈΉΊΌΎΏ±≤ΪΫ÷≈°∙'
    readln;
end.

I searched many posts about this, but I didn't find something useful for me.

PS. No success with all bellow sugestions in both Delphi 2007 & 2010

jim
  • 71
  • 6
  • A [mojibake](https://en.wikipedia.org/wiki/Mojibake) case (example in Python: `'αβγδεζηθικλμνξοπρστυφχψω'.encode( 'cp1253').decode( 'cp737')` returns `'άέήϊίόύϋώΆΈΉΊΌΎΏ±≤ΪΫ÷≈°∙'`). Try changing code page as `chcp 1253` (or `chcp 737`, I'm not sure) _before_ running the app. – JosefZ Oct 15 '21 at 11:47
  • 1
    [Change default code page of Windows console to UTF-8](https://superuser.com/q/269818/388890). This isn't a Delphi problem. The linked question here is asking about changing the default for the console to UTF-8, but I'm sure you can figure out how to make it 1253 instead - the methods are the same. – J... Oct 15 '21 at 12:17
  • In my PCs cmdline and everywhere I can write Greek and non Unicode programs work right. Only a delphi console app, like the test one in my first post, writes in console garbages. That seems to be a problem in my Delphi code. Maby I must change codePage to 1253/737 but I don't know the way. Besides this, the app would be run at different PCs so changing something in my PC is not an option even solves the problem – jim Oct 15 '21 at 18:29
  • 1
    Does this answer your question? [Is Writeln capable of supporting Unicode?](https://stackoverflow.com/questions/26255148/is-writeln-capable-of-supporting-unicode) – whosrdaddy Oct 16 '21 at 10:35
  • My computer has Ukrainian locale. Windows code page for ANSI apps is 1251, but default console codepage is 866. In pre Delphi2009 era I had to manually convert output, but now I simply add "DefaultSystemCodePage := GetConsoleCP;" as the first line of all my console apps. – Torbins Oct 18 '21 at 14:40
  • @whosrdaddy. No, the problem remains. I tried with Delphi 2007 and 2010. The same. I've abandon the solution with console application. – jim Oct 20 '21 at 04:49

0 Answers0