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

adding an emoji triggered an exception #1282

Closed
BananaAcid opened this issue Jan 4, 2020 · 4 comments
Closed

adding an emoji triggered an exception #1282

BananaAcid opened this issue Jan 4, 2020 · 4 comments
Labels
Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@BananaAcid
Copy link

BananaAcid commented Jan 4, 2020

First I tried copy and pasting to the console (used some parts of the config file).

Then I added an emoji using win+., added a space between these ?? that appeared instead of the emoji and pressed enter

Was wondering, why an emoji would not show up on the terminal.

Output

Letzte 200 Tasten:
 5 8 - b 9 8 9 - 0 a 9 9 8 e c 4 4 1 b 8 Ctrl+Alt+} " , Ctrl+Enter Space Space Space Space Space Space Space Space " h i d d e n " : Space f a l s e , Ctrl+Enter Space Space Space Space Space Space Space Space " n a m e " : Space " A z u r e Space C l o u d Space S h e l l " , Ctrl+Enter Space Space Space Space Space Space Space Space " s o u r c e " : Space " W i n d o w s . T e r m i n a l . A z u r e " , Ctrl+Enter Space Space Space Space Space Space Space Space " f o n t F a c e " : Space " F i r a Space C o d e " , Ctrl+Enter Space Space Space Space Space Space Space Space " f o n t S i z e " : Space 8 Ctrl+Enter Space Space Space Space Space Space Ctrl+Alt+} Escape : D Enter
 Escape Ctrl+Alt+? ? Enter


Ausnahme:
System.Text.EncoderFallbackException: Das Unicode-Zeichen \uDD23 im Index 0 kann nicht in die angegebene Codepage übersetzt werden.
   bei System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
   bei System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars)
   bei System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, EncoderNLS baseEncoder)
   bei System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
   bei System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   bei System.IO.StreamWriter.Dispose(Boolean disposing)
   bei System.IO.TextWriter.Dispose()
   bei Microsoft.PowerShell.PSConsoleReadLine.<>c__DisplayClass81_0.<WriteHistoryRange>b__0()
   bei Microsoft.PowerShell.PSConsoleReadLine.WithHistoryFileMutexDo(Int32 timeout, Action action)
   bei Microsoft.PowerShell.PSConsoleReadLine.MaybeAddToHistory(String result, List`1 edits, Int32 undoEditIndex, Boolean fromDifferentSession, Boolean fromInitialRead)
   bei Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   bei Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

image


Environment data

PS version: 5.1.18362.145
PSReadline version: 2.0.0-beta2
os: 10.0.18362.530 (WinBuild.160101.0800)
PS file version: 10.0.18362.530 (WinBuild.160101.0800)
HostName: ConsoleHost (Windows Terminal)
BufferWidth: 154
BufferHeight: 39

Steps to reproduce or exception report

"Type" an emoji, add a space between the 2 ?? and press enter.

@msftrncs
Copy link
Collaborator

msftrncs commented Jan 5, 2020

I do not believe that ConsoleHost (the terminal that PowerShell and PSReadLine reside in on Windows) supports emoji's.

The exception occurs when the command is being saved to the history file. Of course, this exception causes the command to not execute, but if Enter is pressed again, it should. The exception occurs because the history file writing method doesn't seem to know how to encode an emoji in the selected file format (which I am not sure what format that is).

This would be a duplicate of #949.

@BananaAcid
Copy link
Author

BananaAcid commented Jan 5, 2020

@msftrncs It does actually. Write-Host an emoji works. And inserting an emoji and pressing enter, shows that emoji as command not found. On input it shows "??". Adding a space inbetween (which does not make the multibyte string an emoji anymore) breaks the terminal.

image

@msftrncs
Copy link
Collaborator

msftrncs commented Jan 6, 2020

That is not ConsoleHost, that is Windows Terminal. I missed that in your original post. You are correct, Windows Terminal does support Emoji, but ConsoleHost does not. (This may sound confusing since Windows Terminal is listed as ConsoleHost (WindowsTerminal), because Windows Terminal supports the ConsoleHost API and can host any console app that requires it.)

Do not add a space between the ??. They are not real ?, they are unknown characters in a multipart unicode glyph sequence as required for Emoji's. You are receiving the exception because you added the space between the two glyphs that Windows PowerShell 5.1/PSReadLine 2.0.0.-beta2 doesn't directly know how to support on its input line, and now the glyphs make no sense to the unicode handler.

So there really is no issue here I think.

Also, you might find the latest version of PSReadLine (2.0.0-rc1) supports these characters better.

Sorry for any previous confusion.

@daxian-dbw
Copy link
Member

The EncoderFallbackException itself is the same as reported in #949. I will close this issue as a duplicate.
But please try out the 2.0.0-rc1 from PowerShell Gallery. Feel free to log an issue if you can anything else that is off.

@daxian-dbw daxian-dbw added the Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. label Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

3 participants