Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New prompt, alert and confirm methods get confused when escaping special characters [ã] #8179

Closed
pedropaulosuzuki opened this issue Oct 29, 2020 · 6 comments · Fixed by #8199
Labels
bug Something isn't working correctly cli related to cli/ dir windows Related to Windows platform

Comments

@pedropaulosuzuki
Copy link

pedropaulosuzuki commented Oct 29, 2020

The new adition of prompt, alert and confirm methods are great news for all of us!! Glad to have those!

However, after the small #8146 issue, there is yet another unrelated problem with the new tools: special UTF-8 (maybe UTF-16?) characters (ãñõâêîôûü, for example):

image

It happens both on the alert/confirm/prompt message and on the return value. This does not happen on console.log, though. May be related or similar to old #5046.

deno 1.5.0
v8 8.7.220.3
typescript 4.0.3

@kitsonk kitsonk added bug Something isn't working correctly cli related to cli/ dir labels Oct 29, 2020
@lucacasonato lucacasonato added the windows Related to Windows platform label Oct 29, 2020
@pedropaulosuzuki
Copy link
Author

May have something to do with this. But not sure.

@pedropaulosuzuki
Copy link
Author

pedropaulosuzuki commented Oct 30, 2020

Another example, this time with some kanji.

image

console.log(prompt('My prompt: 你好;').trim());

Latin example:

console.log(prompt('My prompt: ãõâêîôûüïáéíóúàèìòùç;').trim());

One more example:
When running the code below and inserting the characters 'a' and 'ã', one at a time, this is what we get:

const a = prompt('Insert your character');

console.log(`a===a => ${a === 'a'}`);  // When inserting the character 'a', returns true, as expected!
console.log(`ã===ã => ${a === 'ã'}`); // When inserting the character 'ã', returns false...

@kt3k
Copy link
Member

kt3k commented Oct 30, 2020

I found that Deno.stdout.writeSync(new TextEncoder().encode("ã")) causes the same problem (tested in powershell in windows).

スクリーンショット 2020-10-30 17 55 14

It seems that Deno.core.print can be a workaround.

@sanderhahn
Copy link
Contributor

Was looking at the rustyline crate and it seems to use utf16 for reading input: https://github.com/kkawakam/rustyline/blob/master/src/tty/windows.rs#L105

@kt3k
Copy link
Member

kt3k commented Oct 31, 2020

#8199 fixes the output of non-ascii characters, but the problem in reading non-ascii chars from stdin (in windows) is still remaining. The above utf-16 decoding could be a solution.

Addition of utf-16 encoding is in progress at #8108

@pedropaulosuzuki
Copy link
Author

pedropaulosuzuki commented Nov 3, 2020

@piscisaureus I don't know if we can call this issue fully fixed. The output part of it is solved, it seems, but the input part of it is still nor recognizing special UTF-16 characters.

For example, when running the code below and inserting the characters 'a' and 'ã', one at a time, this is what we get:

const a = prompt('Insert your character');

console.log(`a===a => ${a === 'a'}`);  // When inserting the character 'a', returns true, as expected!
console.log(`ã===ã => ${a === 'ã'}`); // When inserting the character 'ã', returns false, not what we expected.

Maybe we can open a new issue just for the input part, or reopen this one.

Edit: opened new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir windows Related to Windows platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants