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 method gets confused when receiving special characters as input [ã] #8239

Closed
Tracked by #11936
pedropaulosuzuki opened this issue Nov 4, 2020 · 9 comments
Labels
bug Something isn't working correctly cli related to cli/ dir windows Related to Windows platform

Comments

@pedropaulosuzuki
Copy link

pedropaulosuzuki commented Nov 4, 2020

While #8179 got partially fixed by #8199 (nice one btw, thanks for everyone involved!!), the prompt method still has some issues regarding input (related to stdin). For example, the code below doesn't perform as expected when non-ascii characters are used.

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.

Opened a new issue because the other one got closed before this got adressed.

@pedropaulosuzuki pedropaulosuzuki changed the title New prompt method gets confused when receiving special characters as inputs [ã] New prompt method gets confused when receiving special characters as input [ã] Nov 4, 2020
@kitsonk kitsonk added bug Something isn't working correctly cli related to cli/ dir windows Related to Windows platform labels Nov 5, 2020
@wperron
Copy link
Contributor

wperron commented Nov 5, 2020

Can confirm on Windows on 1.5.1 (In PowerShell, if that has any impact):

Deno 1.5.1
exit using ctrl+d or close()
> 'a' === 'ã'
false

Can also confirm that Linux works fine (tested on Ubuntu 20.04)

Deno 1.5.1
exit using ctrl+d or close()
> 'a' === 'ã'
false
> 'a' == 'ã'
false
> const target = 'ã';
undefined
> const answer = prompt("enter a char");
enter a char ã
undefined
> target === answer
true

@zhmushan
Copy link
Contributor

As I pointed out in #8492, const c = new Uint8Array(1) will cause the read content to be lost (because some characters are more "wider"). This should not be a Windows unique problem.

@F3n67u
Copy link
Contributor

F3n67u commented Jul 31, 2021

Cannot reproduce on my computer.

~ % deno
Deno 1.12.2
exit using ctrl+d or close()
> const a = prompt('Insert your character');
Insert your character ã
undefined
> console.log(`ã===ã => ${a === 'ã'}`);
ã===ã => true
undefined

System Info:
MacOs 11.2.3
deno 1.12.2

@pedropaulosuzuki Can you confirm this is still an issue?

@pedropaulosuzuki
Copy link
Author

Cannot reproduce on my computer.

~ % deno
Deno 1.12.2
exit using ctrl+d or close()
> const a = prompt('Insert your character');
Insert your character ã
undefined
> console.log(`ã===ã => ${a === 'ã'}`);
ã===ã => true
undefined

System Info:
MacOs 11.2.3
deno 1.12.2

@pedropaulosuzuki Can you confirm this is still an issue?

I'd like to, but I dropped Windows on december 31 2020, so now I'm running on Pop!_OS 21.04, on which I cannot test the Windows behaviour with Deno input, unfortunately. Maybe someone with a Windows build could test it and see it the issue persists.

@ayame113
Copy link
Contributor

ayame113 commented Aug 1, 2021

I can confirm that the problem still occurs on windows.

Windows 10.0.19042.1110
Deno 1.12.2
C:\Users\azusa>deno
Deno 1.12.2
exit using ctrl+d or close()
> const a = prompt('Insert your character');
Insert your character ã
undefined
> console.log(`ã===ã => ${a === 'ã'}`);
ã===ã => false
undefined

Maybe prompt() will not accept input of multibyte characters.

C:\Users\azusa>deno
Deno 1.12.2
exit using ctrl+d or close()
> prompt()
Prompt ã
"a"
> prompt()
Prompt こんにちは
"�����"
>

@caspervonb
Copy link
Contributor

Cannot reproduce on my computer.

~ % deno
Deno 1.12.2
exit using ctrl+d or close()
> const a = prompt('Insert your character');
Insert your character ã
undefined
> console.log(`ã===ã => ${a === 'ã'}`);
ã===ã => true
undefined

System Info:
MacOs 11.2.3
deno 1.12.2

@pedropaulosuzuki Can you confirm this is still an issue?

You're trying to reproduce a Windows bug on a Mac.

@F3n67u
Copy link
Contributor

F3n67u commented Aug 1, 2021

Cannot reproduce on my computer.

~ % deno
Deno 1.12.2
exit using ctrl+d or close()
> const a = prompt('Insert your character');
Insert your character ã
undefined
> console.log(`ã===ã => ${a === 'ã'}`);
ã===ã => true
undefined

System Info:
MacOs 11.2.3
deno 1.12.2
@pedropaulosuzuki Can you confirm this is still an issue?

You're trying to reproduce a Windows bug on a Mac.

My bad. I am still learning issue triage.

@rafawalter
Copy link

rafawalter commented Aug 18, 2021

This is still an issue.

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

const textEncoder = new TextEncoder()
console.log(`a: ${textEncoder.encode('a')}`)
console.log(`ã: ${textEncoder.encode('ã')}`)
console.log(`input: ${textEncoder.encode(input || '')}`)
Insert your character ã
�===a => false
�===ã => false
a: 97
ã: 195,163
input: 239,191,189

System Info:
Windows 10 Pro 20H2 19042.1083
Deno 1.13.1

@ry ry mentioned this issue Sep 7, 2021
4 tasks
@marvinhagemeister
Copy link
Contributor

Just tried to reproduce it with the latest Deno release, but wasn't able to. It works as expected for me. Not sure which exact version resolved this, but updating to the latest Deno version will.

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

No branches or pull requests

9 participants