question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minimal view in Write-progress should not depend on code page settings

See original GitHub issue

Prerequisites

Steps to reproduce

When trying to output unicode characters with Write-Progress, they all show up as ?-marks. Using the same text/variable with Write-Host works fine.

Expected behavior

$str = '🦄❤️🌈阳山伟伟'
$count = 1
While ($count -lt 100) {
	Write-Progress -Status $str -PercentComplete $count -Activity "`u{1F4A9}"
	$count++
	Start-Sleep -Milliseconds 10
}

Actual behavior

Both -Status and -Activity texts output `?` instead of the actual characters.

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.7
PSEdition                      Core
GitCommitId                    7.2.7
OS                             Microsoft Windows 10.0.22623
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

image

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jhoneillcommented, Oct 27, 2022

Yes that is going be part of the same problem.
Internally .NET strings are UTF16 Something like 💃 which is 0x01f483 can’t be represented as a 16 bit number so it becomes two 16 bit ones. 0xd83d and 0xdc83 - this range identifies numbers which need to be combined - the we subtract d800 from one and dc00 from the other and the output is 0x10000 + 0x400 * 3d + 83

When the string with [0xd83d] [0xdc83] is output it’s merged back to [0x01f483] and 💃 is printed. However if something says “I need to insert an ANSI escape Sequence after the first character” then we get
`e[7m [0xd83d] `e[0m [0xdc83] For reverse, first char, reset, second char. Which gives nonsense output. This doesn’t impact most unicode because most of the characters are 16 bit values, but it will hit unicode emojis

1reaction
jhoneillcommented, Oct 26, 2022

@kimipsen Actually that does indicate a problem. Can you please edit the title (see below) And thanks for doing the extra step to find the cause.

This should not depend on the codepage selected. On one computer I have that setting and can’t repro the issue. On the computer I am using now (provide by the client I’m working for and set up by their IT people without giving me admin rights) the issue DOES repro and chcp says I’m using code page 437 - just like I used on DOS 3.1 in the 1980s 😃

There if I select classic view for progress image

all good. The terminal , powershell, and Write-Progress can all display UTF 16 strings correctly. If I switch to minimal view something like the € sign which is not in code page 437 or the ellipsis (…) which is a two-byte unicode character both cause failures with the minimal view

image

This issue should be have title like Minimal view in Write-progress should not depend on code page settings . It can’t output characters which classic view CAN output I would say that is a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerShell - Overwriting line written with Write-Host
You cannot overwrite a line in a Powershell window. What you can do is blank the window with cls (Clear-Host): # loop code...
Read more >
Using PowerShell with $PSStyle
In this post, I show you how you can use ANSI rendering to control text decorations, such as color and font styling, in...
Read more >
Windows commands: CMD and PowerShell - Azure
View and Edit Windows Registry Settings using CMD; Manage Windows Services ... While Azure VMs do not support the ability to access WinRE, ......
Read more >
Export-PSSession (Microsoft.PowerShell.Utility)
This command shows that the PSSession need not be active to use the commands that were imported from the session. The Import-Module cmdlet...
Read more >
Events by tag • Akka Persistence Cassandra - Documentation
The events by tag stream updates the Cassandra query it uses to start from the latest offset to avoid reading events it has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found