PSReadLine
PSReadLine copied to clipboard
Exception thrown when using -replace with explicit unicode character
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues, especially the pinned issues.
Exception report
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!
### Environment
PSReadLine: 2.3.5+2cc85806c561a9395751a96a818e8ff1592d19f7
PowerShell: 7.4.3
OS: Microsoft Windows 10.0.19045
BufferWidth: 80
BufferHeight: 41
Last 200 Keys:
t h Spacebar " D : \ a d k Spacebar M u s i c \ � � * . m 3 u 8 " Spacebar - d e s t i n a t i o n Spacebar W M P Spacebar - R e c u r s e LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow Spacebar Backspace Backspace Spacebar LeftArrow M o z Tab Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace D : \ a d k Spacebar M u s i c \ M o z a r t - Spacebar S a l z b u r g Spacebar S y m p h o n i e s \ Delete End Backspace Backspace Backspace Backspace Backspace Backspace Backspace V e r b o s e Spacebar - D e b u g Spacebar - C o n f i r m Backspace Backspace Backspace Backspace Backspace m f o r Backspace Backspace Backspace Backspace n Tab Enter
### Exception
System.Text.EncoderFallbackException: Unable to translate Unicode character \\uDCBF at index 72 to specified code page.
at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
at System.Text.Encoding.GetBytesWithFallback(Char* pOriginalChars, Int32 originalCharCount, Byte* pOriginalBytes, Int32 originalByteCount, Int32 charsConsumedSoFar, Int32 bytesWrittenSoFar, EncoderNLS encoder)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Dispose(Boolean disposing)
at Microsoft.PowerShell.PSConsoleReadLine.<>c__DisplayClass103_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, Nullable`1 lastRunStatus)
Screenshot
Environment data
PS Version: 7.4.3
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.5
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 80
BufferHeight: 41
Steps to reproduce
I ran the commands $ . .\Update-Playlist.ps1 $ Update-Playlist -PlaylistPath "D:\adk Music\Mozart- Salzburg Symphonies\�*.m3u8" -destination WMP -Verbose -Debug -Confirm where the file Update-Playlist.ps1 (renamed Update-Playlist.txt) is attached. Update-Playlist.txt
Expected behavior
No exception should be thrown.
Actual behavior
An exception happens.