readLineSync does not support reading Chinese characters from the command line

 Flutter (Channel stable, 3.27.2, on Microsoft Windows [版本 10.0.19045.5487], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)

i use vscode terminal,language: chinese

import 'dart:io';

void main() {
  stdout.write("Enter your name : ");
  var res = stdin.readLineSync();
  print(res);
}

When I type a Chinese and enter, I want to get res in Chinese, and the result is garbled

How do I get Chinese input ?

Have you tried specifying the encoding -

 var res = stdin.readLineSync(encoding: utf8));

You’ll need to import dart:convert.

That’s not gonna work either.

Its logging an ‘unfinished UTF-8 octet sequence’ so whatever encoding your sender using its not looking as though its UTF-8 or its malformed.

You need to check what encoding your sender is using and decode the string appropriately.

Neither gbk nor utf8 can parse Chinese

I’m not really talking about the language, I’m talking about the encoding function used to encode the characters. A quick google search gives -

What is the best encoding for Chinese characters?
The best encoding for Simplified Chinese characters is UTF-8. UTF-8 is a variable-width character encoding that can represent every character in the Unicode character set, which includes all Chinese characters. Here are some reasons why UTF-8 is preferred:18 

So apparently UTF-8 can encode Chinese characters.

Under normal circumstances utf-8 is OK, including nodejs, you can also enter Chinese in console stdin and display it, but dart is not OK