Skip to content

Windows Console and Unicode #28571

Closed
Closed
@goderbauer

Description

@goderbauer

It seems like Dart cannot properly print unicode characters to the Windows console (cmd.exe or powershell.exe seem to be equally affected). Example test.dart Program:

main() {
  print("These are three black spades: ♠♠♠");
}

Actual console output of dart test.dart:

These are three black spades: ΓÖáΓÖáΓÖá

Ideally, this should have shown the three spades, or - in case those are not available in the font used in the console - it should have show Unicode's missing character symbol (e.g. �).

While researching this issue on the web I realized that properly printing Unicode to the Windows console is actually fairly hard to do. However, it seems like the people over at Python just figured out how to properly do this in python 3.6.0, which was just released last month. Example test.py program:

#!/usr/bin/python
# -*- coding: utf-8 -*-

print("These are three black spades: ♠♠♠")

Actual console output of python test.py (requires python 3.6.0!):

These are three black spades: ♠♠♠

Yeah! \o/

It would be most awesome-st if Dart could also fix the unicode printing behavior on Windows. That would really help us in Flutter, where we make extensive use of unicode in console output (flutter/flutter#7714).

In case it is helpful, here are the relevant discussions around fixing this in python:

From the python discussions, it seems like WriteConsoleW() from the Windows API should be used to write strings to the console in order to get unicode support.

Metadata

Metadata

Assignees

Labels

area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.customer-flutterlibrary-ioos-windowstype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions