-
Notifications
You must be signed in to change notification settings - Fork 304
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
Faied to input emoji in windows terminal (and vscode) #2358
Comments
@codehz Did you use the hotkey Otherwise copying and pasting emoji works normally. The only problem is when I use that hotkey.
those codepoints are a surrogate key. It looks like it's encoding as I tried each of the following, then re-tried $OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [Text.Encoding]::GetEncoding('utf-16')
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [Text.Encoding]::GetEncoding('utf-16le')
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [Text.Encoding]::GetEncoding('utf-8') Working: From clipboard🐒> pwsh -nop -nol
PS C:\Users\cppmo_000\Documents\2020\powershell>
>> '🐒' * 3
🐒🐒🐒 Crashes: Using
|
@ninmonkey yes, I use win+. to input emoji, it seems only works in wsl(with Windows Terminal)(cmd.exe is also failed to receive emoji) |
This bug also seems to happen when pasting emojis. |
I've seen the discussion. The essence of this problem is that PSReadline cannot correctly recognize surrogate pair characters. Surrogate pair characters are famous for emoji, but they are also used to represent lesser-known kanji in Japanese (kanji). An example of a list of surrogate pair kanji can be found at https://www.magata.net/memo/index.php?%A5%B5%A5%ED%A5%B2%A1%BC%A5%C8%A5%DA%A5%A2. (Japanese) I used Windows Terminal and typed PowerShell (7.1.3, PSReadLine 2.2.0-beta3)
The error is exactly the same as the log attached by the other person. However, if you enter Since only one PowerShell (7.1.3, remove PSReadLine)
The characters are garbled in the input, but they are displayed normally in the output. From this, it can be seen that the problem of garbled input is a problem of PowerShell itself, and it is a problem of PSReadline that an error occurs when reading surrogate pair characters. Windows PowerShell (5.1, PSReadLine 2.0.0-beta2)
The input shows If you run cmd.exe
It is in the same state as The characters are garbled in the input, but they are displayed normally in the output. Since I am using translation, the text may be unnatural. |
When I looked it up, I found something strange. First of all, this issue does not occur at all in PSReadline 1.2. In addition, PSReadline 1.2 does not cause garbled characters when entering surrogate pair characters. This is the same for both Windows PowerShell 5.1 and PowerShell 7. While using PSReadline 1.2, I ran 🔼 PSReadline 2.0.0-beta2 bundled with Windows 10 2004 What's more, strangely, PSReadline 2.0.0-beta2 bundled with Windows 10 2004 seems to be different from PSReadline 2.0.0-beta2 distributed by PowerShellGallery. And I found that only PSReadline 2.0.0-beta2 bundled with Windows 10 2004 did not give an error. So there are currently two workarounds for this issue in PowerShell 7. I'd like to avoid downgrading as much as possible, but I can't help it because the previous version solves the problem. If this problem is left unattended, it's a shame. |
I'm not sure if it's the same issue or a different one, (it seems similar) some unicode characters are interpreted as 2-wide instead of 1-wide, but the resulting additional space(s) appear at the next change of color: (here with 𝔼, there is an additonal space between the red part and the orange one) due to this same issue, the caret is also not at the right place when typing
|
I met this too. EnvironmentPSReadLine: 2.1.0 Last 195 Keys
Exception
|
I experienced this too , entering smiley into a string variable in the console line of Visual Studio Code. Since this issue still is open, I don't need to submit a new bug report 😁 PS Version: 5.1.22000.832 |
hello, To reproduce, open windows terminal, type
Environment
Last 9 Keys
Exception
|
Hi again, at microsoft/terminal they pointed me to this repo for resolution, so this should be the right place to post... regarding my previous comment, please see here for more details: microsoft/terminal#14084 |
Environment
PSReadLine: 2.1.0
PowerShell: 7.1.3
OS: Microsoft Windows 10.0.21354
BufferWidth: 120
BufferHeight: 30
Last 36 Keys
(real command line:
git init -b 💡
(Don't paste directly, input with windows emoji panel (win + .
)), windows experimental unicode mode is NOT enabled)Exception
The text was updated successfully, but these errors were encountered: