Skip to content

Need "ANSI" encoding enumeration value to support "ANSI"-code-page-encoded files (e.g., Windows 1252) #6562

@mklement0

Description

@mklement0

As discussed in #6550:

While you can pass OEM to filesystem cmdlets to support the legacy system locale's OEM code page on Windows, its "ANSI" counterpart (such as Windows 1252 on US-English systems) is currently missing.
(In Windows PowerShell, the Default value fulfills that role, but in PowerShell Core Default now refers to the new default, (BOM-less) UTF-8.)

Therefore, an ANSI encoding value should be introduced to complement the OEM value.

With ANSI available, the current workaround:

Get-Content -Encoding ([cultureinfo]::CurrentCulture.TextInfo.ANSICodePage) file.txt

would simply become:

Get-Content -Encoding Ansi file.txt   # Wishful thinking.

Note: Given that OEM already is available even when running on Unix-like platforms, it sounds like we shouldn't restrict ANSI's availability to Windows. ([System.Text.Encoding]::GetEncoding([cultureinfo]::CurrentCulture.TextInfo.ANSICodePage)seemingly does return a locale-appropriate value on Unix-like platforms as well.)

Environment data

Written as of:

PowerShell Core v6.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions