-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
First-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Description
Note:
- Windows PowerShell is not affected - UTF-8 with BOM is used consistently there.
- A fix for the closely related Start-Transcript -Append uses lossy ASCII character encoding when appending to a BOM-less target file #13678 could probably encompass a fix for this issue as well.
When the target file happens to exist and doesn't have a BOM - even without -Append - Start-Transcript mistakenly uses ASCII encoding to write the file.
Without -Append, Start-Transcript shouldn't even look at the existing file - it should simply replace it, and use the default encoding (BOM-less UTF-8). See #13678 for a closely related bug with -Append.
Instead, Start-Transcript apparently looks for a BOM at the start of an existing file and uses ASCII encoding if it doesn't find one.
Steps to reproduce
# To surface the bug, make sure that the target file exists and doesn't have a BOM.
$null > temp:/$PID.txt
$null = Start-Transcript 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 ?, suggesting that ASCII encoding was used to write the file.
Environment data
PowerShell Core 7.1.0-preview.7
Metadata
Metadata
Assignees
Labels
First-Time-IssueEasy issues first time contributors can work on to learn about this projectEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues