digitalmars.D - How do you get unicode support on terminal input to Visual D program?
- Fruitful Approach (3/3) May 07 2020 I'm writing a type theory interpreter, so the character `λ` is
- Adam D. Ruppe (21/24) May 07 2020 There's a few possible answers depending on what exactly you're
I'm writing a type theory interpreter, so the character `λ` is used a lot. I am able to print it, but `readln()` converts the char to `\0` so my program crashes.
May 07 2020
On Friday, 8 May 2020 at 01:54:42 UTC, Fruitful Approach wrote:I'm writing a type theory interpreter, so the character `λ` is used a lot. I am able to print it, but `readln()` converts the char to `\0` so my program crashes.There's a few possible answers depending on what exactly you're doing. Someone is sure to say "call SetConsoleCP(65001);` and while that kinda sorta works, it isn't great because it has side effects, but is probably the easiest thing to try and might work for you. You can also call ReadConsoleW and get a wstring, this works well unless your program is piped... which Visual D might do, I'm not sure. If it is piped you need to handle that differently with an if branch. This is the next least invasive. There's my terminal.d which also needs an if branch for pipes but it supports all the input cross-platform with other niceties too https://github.com/adamdruppe/arsd or if you use dub https://code.dlang.org/packages/arsd-official%3Aterminal example: http://dpldocs.info/experimental-docs/arsd.terminal.html#get-line And it somewhat recently includes facilities to pop up its own gui window as well, use dub subConfiguration "builtin_emulator" to give that a try. Most invasive but you might like the results.
May 07 2020