Skip to content

emoji would cause to crash #4985

@Mikachu2333

Description

@Mikachu2333

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

### Env
PSReadLine: 2.4.2-beta2
PowerShell: 5.1.26100.6584
OS: Microsoft Windows 10.0.26200
BufferWidth: 95
BufferHeight: 8

Last 90 Keys:

 c a r g o Spacebar c h e c k Enter
 u n i c o d e Spacebar 2 6 Spacebar 1 Backspace Backspace 1 6 Enter
 UpArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Backspace 7 Enter
 c a r g o Spacebar c h e c k Enter
 c a r g o Spacebar r Spacebar - - Spacebar u + 1 F 6 0 0 Enter
 UpArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Spacebar t e s t Enter
 UpArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Spacebar Backspace � Enter


### Exception

System.Text.EncoderFallbackException: 无法将位于索引 23 处的 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__DisplayClass104_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, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

Image

Environment data

PSReadLine: 2.4.2-beta2
PowerShell: 5.1.26100.6584
OS: Microsoft Windows 10.0.26200
BufferWidth: 95
BufferHeight: 8

Steps to reproduce

I try to input 🦊 ( U+1F98A) to pwsh in VSCode terminal env and press enter

Expected behavior

do not crash

Actual behavior

crash

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions