Skip to main content This browser is no longer supported. Show
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. about_Character_Encoding
In this articleShort descriptionDescribes how PowerShell uses character encoding for input and output of string data. Long descriptionUnicode is a worldwide character-encoding standard. The system uses Unicode exclusively for character and string manipulation. For a detailed description of all aspects of Unicode, refer to The Unicode Standard. Windows supports Unicode and traditional character sets. Traditional character sets, such as Windows code pages, use 8-bit values or combinations of 8-bit values to represent the characters used in a specific language or geographical region settings. PowerShell uses a Unicode character set by default. However, several cmdlets have an Encoding parameter that can specify encoding for a different character set. This parameter allows you to choose the specific the character encoding you need for interoperability with other systems and applications. The following cmdlets have the Encoding parameter:
The byte-order-markThe byte-order-mark (BOM) is a Unicode signature in the first few bytes of a file or text stream that indicate which Unicode encoding used for the data. For more information, see the Byte order mark documentation. In Windows PowerShell, any Unicode encoding, except For best overall compatibility, avoid using BOMs in UTF-8 files. Unix platforms and Unix-heritage utilities also used on Windows Platforms don't support BOMs. Similarly, Creating PowerShell scripts on a Unix-like platform or using a cross-platform editor on
Windows, such as Visual Studio Code, results in a file encoded using If you need to use non-Ascii characters in your scripts, save them as UTF-8 with BOM. Without the BOM, Windows PowerShell misinterprets your script as being encoded in the legacy "ANSI" codepage. Conversely, files that do have the UTF-8 BOM can be problematic on Unix-like platforms. Many Unix tools
such as Character encoding in Windows PowerShellIn PowerShell 5.1, the Encoding parameter supports the following values:
In general, Windows PowerShell uses the Unicode UTF-16LE encoding by default. However, the default encoding used by cmdlets in Windows PowerShell is not consistent. Note Using any Unicode encoding, except For cmdlets that write output to files:
For commands that append to an existing file:
For cmdlets that read string data in the absence of a BOM:
Character encoding in PowerShellIn PowerShell (v6 and higher), the Encoding parameter supports the following values:
PowerShell defaults to Beginning with PowerShell 6.2, the Encoding parameter also allows numeric IDs of registered code pages (like Changing the default encodingPowerShell has two default variables that can be used to change the default encoding behavior.
For more information, see about_Preference_Variables. Beginning in PowerShell 5.1, the
redirection operators (
Use the following statement to change the default encoding for all cmdlets that have the Encoding parameter.
Important Putting this command in your PowerShell profile makes the preference a session-global setting that affects all commands and scripts that do not explicitly specify an encoding. Similarly, you should include such commands in your scripts or modules that you want to behave the same way. Using these commands ensure that cmdlets behave the same way even when run by another user, on a different computer, or in a different version of PowerShell. The automatic variable See also
FeedbackSubmit and view feedback for Which of the following commands will change the SELinux security context of a file?1. Temporary Changes: chcon. The chcon command changes the SELinux context for files.
Which of the following is the default window manager used by the gnome?metacity. The Metacity window manager is the default window manager for GNOME.
Which of the following does click assist do?Which of the following does Click Assist do? Simulates a right click by holding down the left mouse button. Which of the following is the default desktop environment used by Linux Mint?
Which of the following is the default desktop environment used by Linux Mint?Cinnamon is the principal desktop environment of the Linux Mint distribution and is available as an optional desktop for other Linux distributions and other Unix-like operating systems as well.
|