Garbled characters after using crt in console application lazarus / 21-General ---------------------------------------------------------------------- iruanpan · 2022-12-15 11:23 I want to use the textcolor in the crt to modify the color of the console text, but the Chinese characters that should appear in the console become "?", I deleted the line of textcolor but it is still "?", I want to know how to solve this problem ,thanks. ---------------------------------------------------------------------- Handoko · 2022-12-15 11:40 I could be wrong. But as far as I know console mode only supports ASCII and extended ASCII characters: https://www.asciitable.com/ ---------------------------------------------------------------------- Thaddy · 2022-12-15 13:28 Not quite. chcp 65001 will switch the console to utf-8. This can also be done in code. In windows 11 the terminal is unicode by default. ---------------------------------------------------------------------- Bart · 2022-12-15 18:09 The crt unit resets codepage upon every write to console, unles otherwise instructed. There are 2 procedures that influence this: - procedure SetSafeCPSwitching - procedure SetUseACP Try fiddling with those. Bart ---------------------------------------------------------------------- iruanpan · 2022-12-16 01:00 Quote from: Bart on December 15, 2022, 07:09:08 pmThe crt unit resets codepage upon every write to console, unles otherwise instructed. There are 2 procedures that influence this: - procedure SetSafeCPSwitching - procedure SetUseACP Try fiddling with those. Bart I wonder how to achieve it, because I tried to call these two procedures in the past, but it didn't work ---------------------------------------------------------------------- Fred vS · 2022-12-16 03:13 Hello. Maybe you will have more luck using the "keyboard" unit. I did have some trouble with "crt" unit and using "keyboard" unit instead did the trick. https://forum.lazarus.freepascal.org/index.php/topic,57284.msg426272.h tml#msg426272 Maybe it could help you too. ---------------------------------------------------------------------- iruanpan · 2022-12-16 08:57 Quote from: Fred vS on December 16, 2022, 04:13:56 amHello. Maybe you will have more luck using the "keyboard" unit. I did have some trouble with "crt" unit and using "keyboard" unit instead did the trick. https://forum.lazarus.freepascal.org/index.php/topic,57284.msg426272.h tml#msg426272 Maybe it could help you too. Thank you but I tried your suggestion and it still doesn't work