PSReadLine: Powershell 7 could unable to translate Unicode character \\uD83D at index 0 to specified code page
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues, especially the pinned issues.
Exception report
### 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.Encoding.GetBytesWithFallback(ReadOnlySpan`1 chars, Int32 originalCharsLength, Span`1 bytes, Int32 originalBytesLength, EncoderNLS encoder)
at System.Text.Encoding.GetBytesWithFallback(Char* pOriginalChars, Int32 originalCharCount, Byte* pOriginalBytes, Int32 originalByteCount, Int32 charsConsumedSoFar, Int32 bytesWrittenSoFar, EncoderNLS encoder)
at System.Text.EncoderNLS.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, 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__DisplayClass99_0.<WriteHistoryRange>b__0()
at Microsoft.PowerShell.PSConsoleReadLine.WithHistoryFileMutexDo(Int32 timeout, Action action)
at Microsoft.PowerShell.PSConsoleReadLine.WriteHistoryRange(Int32 start, Int32 end, Boolean overwritten)
at Microsoft.PowerShell.PSConsoleReadLine.IncrementalHistoryWrite()
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, Nullable`1 lastRunStatus)
Screenshot
Environment data
### Environment
PSReadLine: 2.2.6
PowerShell: 7.3.7
OS: Microsoft Windows 10.0.22621
BufferWidth: 182
BufferHeight: 13
Last 63 Keys:
c d RightArrow Enter
c l s Enter
c d RightArrow Enter
. RightArrow Enter
c d RightArrow Enter
. RightArrow Enter
c d RightArrow Enter
. RightArrow Enter
c l e a e Enter
c l e a r Enter
c d RightArrow Enter
. RightArrow Enter
c l s Enter
c d RightArrow Enter
. RightArrow Enter
� RightArrow LeftArrow Enter
Steps to reproduce
Pasting a lot of unicode encoded emojis from the windows clipboard Note: This error only occured in my visual studio code integrated terminal verision of powershell7; In my windows terminal version of powershell7, it is working just fine, probably because i manipulated the Json file a bit to use Cascadia Code as the font face, but who knows
Expected behavior
Some sort of delay, then an error message is displayed.
Actual behavior
N/A
About this issue
- Original URL
- State: open
- Created 9 months ago
- Comments: 15 (7 by maintainers)
I think this is the older version of conpty that ships with Windows not handling it correctly. We are sending the right character there but this is what we get back (this is from the frontend “Terminal” log):
I also verified that’s what the native API in node-pty is handing off to us (“Pty Host” log):
So this will likely get fixed in a future Windows update.
True, because it seems to only affect most of my vscode’s integrated terminals.
It is set to true on my vscode.
@StevenBucher98 from the screenshot this looks like it’s happening not in the Extension Terminal but in a VS Code hosted terminal with
pwsh
, so the extension seems unrelated. VS Code’s terminals are Xterm.js: https://github.com/xtermjs/xterm.js/