deno-cliffy icon indicating copy to clipboard operation
deno-cliffy copied to clipboard

Broken special character encoding on Windows Terminal

Open prcdpr opened this issue 3 years ago • 3 comments

Windows Terminal supports emoji:

deno run https://deno.land/std/examples/welcome.ts

image

However, cliffy Prompt with emoji prints garbled output instead

import { Input } from "https://deno.land/x/cliffy/prompt/mod.ts";
const name: string = await Input.prompt( {message: `What's your name?`, pointer: '🦕' } );
deno run --unstable https://gist.githubusercontent.com/prcdpr/a202eabe338fc47bcc5e1c80b987f974/raw/39ac37c59ad0efc8bb7b03b02225e7eaafde5bd7/cliffy-prompt-emoji.ts

image

Code gist to test can be found here https://gist.github.com/prcdpr/a202eabe338fc47bcc5e1c80b987f974

prcdpr avatar Nov 22 '20 21:11 prcdpr

Hi @prcdpr, there is an issue with Deno.stdout.write which doesn't handle unicode characters well. There is already an deno issue https://github.com/denoland/deno/issues/6001. But i found a workaourund here https://github.com/denoland/deno/issues/6131#issuecomment-640032166. You have to enable utf8 character encoding in windows than it should work.

c4spar avatar Nov 24 '20 18:11 c4spar

Thanks for finding this. I don't like the solution mentioned as it requires system restart, but following can also be done (copying my another answer):

[Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8

To keep this setting persistent, you can create a %userprofile%/Documents/PowerShell/profile.ps1 with the line above.

prcdpr avatar Nov 24 '20 21:11 prcdpr

Reopening because this is still an issue.

c4spar avatar May 08 '22 13:05 c4spar

Looks like this is now fixed.

c4spar avatar Mar 16 '23 18:03 c4spar