-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
Description
Note: Unlike #13677, Windows PowerShell exhibits the same problem.
Start-Transcript -Append tries to match the target file's existing character encoding.
As an aside: The built-in cmdlets are inconsistent with respect to this behavior: Out-File -Append does not match the existing encoding, whereas Export-Csv -Append, Start-Transcript -Append, and Add-Content do.
In the absence of a BOM in the target file, ASCII encoding is currently assumed, which results in the loss of non-ASCII-range characters, as they are transliterated to verbatim ?.
UTF-8 (by definition BOM-less, since a file is being appended to) should be assumed and used instead.
Steps to reproduce
# To surface the bug, make sure that the target file exists and doesn't have a BOM.
'ä' > temp:/$PID.txt
# Start the transcript and *append* to the existing file:
$null = Start-Transcript -Append temp:/$PID.txt
'ü' # output a string with a non-ASCII-range character
$null = Stop-Transcript
Select-String -Quiet 'ü' temp:/$PID.txt | Should -BeTrue
Remove-Item temp:/$PID.txtExpected behavior
The test should succeed.
Actual behavior
The test fails, because ü was transliterated to verbatim ?.
Environment data
PowerShell Core 7.1.0-preview.7
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a