Unicode Emoji Causes Exception #13249

Closed
opened 2026-01-31 03:37:43 +00:00 by claunia · 3 comments
Owner

Originally created by @0xC4DE on GitHub (Mar 31, 2021).

PSReadLine: 2.0.0
PowerShell: 5.1.21296.1000
OS: Microsoft Windows 10.0.21296

Expected Behavior: Not an exception, does command as usual

Actual Behavior: Causes an exception and prevents any command containing unicode emoji from working, but not every unicode emoji, haven't been able to test which emojis extensively, I have noticed that if they paste and display properly, they do not tend to cause errors, I imagine the traceback is more useful.


### Exception

System.Text.EncoderFallbackException: Unable to translate Unicode character \uD83D at index 0 to specified code page.
at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
at System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars)
at System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, EncoderNLS baseEncoder)
at System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Dispose(Boolean disposing)
at System.IO.TextWriter.Dispose()
at Microsoft.PowerShell.PSConsoleReadLine.<>c__DisplayClass83_0.b__0()
at Microsoft.PowerShell.PSConsoleReadLine.WithHistoryFileMutexDo(Int32 timeout, Action action)
at Microsoft.PowerShell.PSConsoleReadLine.MaybeAddToHistory(String result, List`1 edits, Int32 undoEditIndex, Boolean fromDifferentSession, Boolean fromInitialRead)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)


PS W:\desktop\tiktokdl> �✌✌
Symbols typed in above example, using windows emoji keyboard: 👍✌✌

Originally created by @0xC4DE on GitHub (Mar 31, 2021). PSReadLine: 2.0.0 PowerShell: 5.1.21296.1000 OS: Microsoft Windows 10.0.21296 Expected Behavior: Not an exception, does command as usual Actual Behavior: Causes an exception and prevents any command containing unicode emoji from working, but not every unicode emoji, haven't been able to test which emojis extensively, I have noticed that if they paste and display properly, they do not tend to cause errors, I imagine the traceback is more useful. ``` ### Exception ``` System.Text.EncoderFallbackException: Unable to translate Unicode character \uD83D at index 0 to specified code page. at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index) at System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars) at System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, EncoderNLS baseEncoder) at System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush) at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) at System.IO.StreamWriter.Dispose(Boolean disposing) at System.IO.TextWriter.Dispose() at Microsoft.PowerShell.PSConsoleReadLine.<>c__DisplayClass83_0.<WriteHistoryRange>b__0() at Microsoft.PowerShell.PSConsoleReadLine.WithHistoryFileMutexDo(Int32 timeout, Action action) at Microsoft.PowerShell.PSConsoleReadLine.MaybeAddToHistory(String result, List`1 edits, Int32 undoEditIndex, Boolean fromDifferentSession, Boolean fromInitialRead) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken) ``` PS W:\desktop\tiktokdl> �✌✌ Symbols typed in above example, using windows emoji keyboard: 👍✌✌
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-31 03:37:44 +00:00
Author
Owner

@skyline75489 commented on GitHub (Mar 31, 2021):

This is not a terminal issue, to be exact. I think you should file this at https://github.com/PowerShell/PSReadLine/issues

btw can you try PowerShell Core? I think Windows PowerShell (aka PowerShell 5) is not being actively maintained now.

@skyline75489 commented on GitHub (Mar 31, 2021): This is not a terminal issue, to be exact. I think you should file this at https://github.com/PowerShell/PSReadLine/issues btw can you try PowerShell Core? I think Windows PowerShell (aka PowerShell 5) is not being actively maintained now.
Author
Owner

@0xC4DE commented on GitHub (Mar 31, 2021):

This is not a terminal issue, to be exact. I think you should file this at https://github.com/PowerShell/PSReadLine/issues

btw can you try PowerShell Core? I think Windows PowerShell (aka PowerShell 5) is not being actively maintained now.

Yes, typing these emojis into powershell shows the question marks, but doesnt really care or throw an exception. I believe the issue has to do with how terminal renders/passes unicode, not super sure.

I'd also like to add that the exception thrown can be somewhat ignored by just pressing enter again, although the emojis start behaving weird in the traceback (the powershell one, not quite relevant to this error)

@0xC4DE commented on GitHub (Mar 31, 2021): > This is not a terminal issue, to be exact. I think you should file this at https://github.com/PowerShell/PSReadLine/issues > > btw can you try PowerShell Core? I think Windows PowerShell (aka PowerShell 5) is not being actively maintained now. Yes, typing these emojis into powershell shows the question marks, but doesnt really *care* or throw an exception. I believe the issue has to do with how terminal renders/passes unicode, not super sure. I'd also like to add that the exception thrown can be somewhat ignored by just pressing enter again, although the emojis start behaving weird in the traceback (the powershell one, not quite relevant to this error)
Author
Owner

@0xC4DE commented on GitHub (Mar 31, 2021):

Ah wait. turns out I'm stupid

Oops, something went wrong. Please report this bug with the details below.
Report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new

@0xC4DE commented on GitHub (Mar 31, 2021): Ah wait. turns out I'm stupid > Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13249