deno: windows doesn't print emojis correctly
Hi! This is my first time looking at Deno, and it seems to be very exciting 😃
I was playing around with the examples from the tutorial and noticed this inconsistency: (using powershell and windows terminal):
> deno run https://deno.land/std/examples/welcome.ts
Welcome to Deno 🦕
> deno run --allow-net https://deno.land/std/examples/curl.ts https://deno.land/std/examples/welcome.ts
console.log("Welcome to Deno ÂÆ’ªò");
I found that editing curl.ts
to add the line
import { decode } from "https://deno.land/std/encoding/utf8.ts";
and replacing the Deno.stdout.write
line with
console.log(decode(body));
seems to make the downloaded file print out correctly.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 18 (10 by maintainers)
Deno.stdout.write
writes UTF-8 data but the console code page may be different.If you run
chcp 65001
(65001 = UTF-8) first, the output is as expected.#6131 This problem is the same, I couldn’t display characters with accents.
The details of the problem are explained, and how to solve it under Windows.
#8199
@piscisaureus I just traced the two commands using API Monitor. I can confirm that
console.log
is usingWriteConsoleW
whereasDeno.stdout.write
is usingWriteFile
.Screenshots
That’s true, but here’s the secret: WriteConsoleW doesn’t depend on the code page, it always uses UTF16 (technically UCS2).