【发布时间】:2019-07-12 18:47:13
【问题描述】:
这个answer 有一些代码可以将语言环境转换为Java 中的国家/地区表情符号。我尝试在 Dart 中实现它,但没有成功。
我尝试将上面的代码转换为 Dart
void _emoji() {
int flagOffset = 0x1F1E6;
int asciiOffset = 0x41;
String country = "US";
int firstChar = country.codeUnitAt(0) - asciiOffset + flagOffset;
int secondChar = country.codeUnitAt(1) - asciiOffset + flagOffset;
String emoji =
String.fromCharCode(firstChar) + String.fromCharCode(secondChar);
print(emoji);
}
“美国”语言环境应输出“??????????”
【问题讨论】:
-
使用系统频道,这正是你要找的