Skip to content

PowerShell use Chinese character “” just like "" ? #21437

@MMMMMoris

Description

@MMMMMoris

Prerequisites

Steps to reproduce

Both these two lines of code work in PowerShell.

Write-Host 这是一段中文: This a paragrah of Chinese
Write-Host "这是一段中文: This a paragrah of Chinese"

Did PowerShell just mean to do so or it was just a mistake of our developers ?
I was thinking if it is related to UTF-8 character set.

image

As you can see from the picture above, my Windows was not set to use UTF-8 character set.
Here is the output of $OutputEncoding of my PowerShell

Preamble          :
BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001

Expected behavior

`Write-Host “这是一段中文: This a a paragrah of Chinese”`
Code like this perhaps ought to be wrong.

Actual behavior

`Write-Host “这是一段中文: This a a paragrah of Chinese”`
Code like this works fine in PowerShell.

Error details

No response

Environment data

PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions