EncoderFallbackException, with powershell, chcp 65001 and 😂 #8399

Closed
opened 2026-01-31 01:28:24 +00:00 by claunia · 7 comments
Owner

Originally created by @liuxilu on GitHub (May 21, 2020).

Environment

Windows build number: 10.0.18362.836, ZH-CN
Windows Terminal version (if applicable): v1.0
Any other software? None.

Steps to reproduce

PowerShell:

>chcp 65001
>.\😂

Can't reproduce with PowerShell itself.

Expected behavior

Run the command, or throw CommandNotFoundException.

Actual behavior

��ѽ���������⡣���ڱ���� Bug ʱ���������ϸ��Ϣ��
�� GitHub �ϱ���: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
�� 15 ����Կ:
 c h c p Space 6 5 0 0 1 Enter
 . \ ? Enter


�쳣:
System.Text.EncoderFallbackException: �޷���λ������ 2 ���� Unicode �ַ� \uD83D ת��Ϊָ���Ĵ���ҳ��
   �� System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
   �� System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars)
   �� System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, EncoderNLS baseEncoder)
   �� System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
   �� System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   �� System.IO.StreamWriter.Dispose(Boolean disposing)
   �� System.IO.TextWriter.Dispose()
   �� Microsoft.PowerShell.PSConsoleReadLine.<>c__DisplayClass81_0.<WriteHistoryRange>b__0()
   �� Microsoft.PowerShell.PSConsoleReadLine.WithHistoryFileMutexDo(Int32 timeout, Action action)
   �� Microsoft.PowerShell.PSConsoleReadLine.MaybeAddToHistory(String result, List`1 edits, Int32 undoEditIndex, Boolean fromDifferentSession, Boolean fromInitialRead)
   �� Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   �� Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
Originally created by @liuxilu on GitHub (May 21, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.18362.836, ZH-CN Windows Terminal version (if applicable): v1.0 Any other software? None. ``` # Steps to reproduce PowerShell: ``` >chcp 65001 >.\😂 ``` Can't reproduce with PowerShell itself. # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> Run the command, or throw CommandNotFoundException. # Actual behavior <!-- What's actually happening? --> ``` ��ѽ���������⡣���ڱ���� Bug ʱ���������ϸ��Ϣ�� �� GitHub �ϱ���: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- �� 15 ����Կ: c h c p Space 6 5 0 0 1 Enter . \ ? Enter �쳣: System.Text.EncoderFallbackException: �޷���λ������ 2 ���� Unicode �ַ� \uD83D ת��Ϊָ���Ĵ���ҳ�� �� System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index) �� System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars) �� System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, EncoderNLS baseEncoder) �� System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush) �� System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) �� System.IO.StreamWriter.Dispose(Boolean disposing) �� System.IO.TextWriter.Dispose() �� Microsoft.PowerShell.PSConsoleReadLine.<>c__DisplayClass81_0.<WriteHistoryRange>b__0() �� Microsoft.PowerShell.PSConsoleReadLine.WithHistoryFileMutexDo(Int32 timeout, Action action) �� Microsoft.PowerShell.PSConsoleReadLine.MaybeAddToHistory(String result, List`1 edits, Int32 undoEditIndex, Boolean fromDifferentSession, Boolean fromInitialRead) �� Microsoft.PowerShell.PSConsoleReadLine.InputLoop() �� Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- ```
Author
Owner

@zadjii-msft commented on GitHub (May 21, 2020):

I'm pretty sure the garbage text that looks like

��ѽ���������⡣���ڱ���� Bug ʱ���������ϸ��Ϣ��
�� GitHub �ϱ���: https://github.com/lzybkr/PSReadLine/issues/new

Is supposed to be saying "Please report this issue over at https://github.com/lzybkr/PSReadLine/issues/new". I'd bet that PSReadline doesn't really work with UTF-8 all that well.

@zadjii-msft commented on GitHub (May 21, 2020): I'm pretty sure the garbage text that looks like ``` ��ѽ���������⡣���ڱ���� Bug ʱ���������ϸ��Ϣ�� �� GitHub �ϱ���: https://github.com/lzybkr/PSReadLine/issues/new ``` Is _supposed_ to be saying "Please report this issue over at https://github.com/lzybkr/PSReadLine/issues/new". I'd bet that PSReadline doesn't really work with UTF-8 all that well.
Author
Owner

@liuxilu commented on GitHub (May 22, 2020):

Needs-Author-Feedback, What feedback?

Can't reproduce with PowerShell itself.

@liuxilu commented on GitHub (May 22, 2020): Needs-Author-Feedback, What feedback? > Can't reproduce with PowerShell itself.
Author
Owner

@liuxilu commented on GitHub (May 22, 2020):

What a fast msftbot!

@liuxilu commented on GitHub (May 22, 2020): What a fast msftbot!
Author
Owner

@zadjii-msft commented on GitHub (May 22, 2020):

If what you mean by

Can't reproduce with PowerShell itself.

is "I removed PSReadline and the issue goes away", then this is definitely an issue that should be filed over at https://github.com/lzybkr/PSReadLine/issues/new. Thanks for following up!

@zadjii-msft commented on GitHub (May 22, 2020): If what you mean by > Can't reproduce with PowerShell itself. is "I removed PSReadline and the issue goes away", then this is _definitely_ an issue that should be filed over at https://github.com/lzybkr/PSReadLine/issues/new. Thanks for following up!
Author
Owner

@liuxilu commented on GitHub (May 23, 2020):

It only appears when using PowerShell through Windows Terminal. Sorry for my bad expression.

@liuxilu commented on GitHub (May 23, 2020): It only appears when using PowerShell through Windows Terminal. Sorry for my bad expression.
Author
Owner

@liuxilu commented on GitHub (Aug 18, 2020):

@zadjii-msft

@liuxilu commented on GitHub (Aug 18, 2020): @zadjii-msft
Author
Owner

@zadjii-msft commented on GitHub (Aug 18, 2020):

Sorry, this must have gotten lost in the inbox. Looking through the PSReadline repo, it looks like they're tracking this issue over at PowerShell/PSReadLine#949. That'll probably be the best thread to contribute to. Thanks!

@zadjii-msft commented on GitHub (Aug 18, 2020): Sorry, this must have gotten lost in the inbox. Looking through the PSReadline repo, it looks like they're tracking this issue over at [PowerShell/PSReadLine#949](https://github.com/PowerShell/PSReadLine/issues/949). That'll probably be the best thread to contribute to. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8399