1

I'm a beginner in Dart. I want to write a program that takes an input and print it with some predefined text. This is how my code looks like:

import 'dart:convert';
import 'dart:io';

main() {
  print('What is your name?');
  print('Hello ${stdin.readLineSync(encoding: utf8)}');
}

And this is the how the command line looks like:

What is your name?
Leó Takács
Hello Le Takcs

It's just delete all the special characters. I think the problem is with the readLineSync because I tried printing 'Leó' and it works that way. My Dart SDK version is 2.14.2 by the way.

Thanks for your help!

TLeo
  • 76
  • 6

1 Answers1

0

It works for me (on Linux in an rxvt-unicode terminal). That suggests that the problem isn't necessarily in the Dart platform code, or at least it's platform specific.

What platform are you running on? What console are you using? Is the console in fact UTF-8, or is it Latin-1 or Windows-1252? Try changing to encoding: latin1 and see if it makes a difference.

lrn
  • 64,680
  • 7
  • 105
  • 121
  • Hey, Thanks for your answer! I'm using Windows cmd with all the default settings and the same python program is working just fine in it. I tried latin1 encoding but it's not working either. – TLeo Nov 04 '21 at 17:34
  • I can see the same problem on Windows, and no immediate guess to a workaround. – lrn Nov 04 '21 at 18:51