36

Is there any way to find what is the default character encoding in Windows? I know that in Western Europe and the US, CP-1252 is the default, but need to check this on other Windows machines too.

Alternatively, is there any list of default encodings per locale?

4
  • It is related to customer support, not programming. The control panel applet has been renamed in every Windows version. XP calls it "Regional and Language Options" iirc, Win7 calls it "Region and Language", Win8 calls it "Region". Given that you are interested in different code pages, you'll have to figure out the localized name for the applet to give the customer the correct instructions. Perhaps a little program you write yourself starts sounding attractive? Commented Nov 5, 2013 at 19:29
  • The default character encoding on Windows is UTF-16. What you may be referring to is the default legacy codepage that is used for ancient non-Unicode applications and all the ANSI API functions (which honestly should never be relevant for current software, alas it sadly all too often is).
    – Joey
    Commented Nov 6, 2013 at 6:12
  • @Joey: Right. Unfortunately I have to read files which were generated by these ancient non-Unicode applications :-/
    – Grodriguez
    Commented Nov 6, 2013 at 17:40
  • 2
    @HansPassant: Sorry, but it is not related to customer support, it is related to programming. I don't want to give any instructions to the customer. That's the point of my question. I need my code to be able to read files generated by a non-Unicode application, and for that I need to know the default encoding based on the user's locale.
    – Grodriguez
    Commented Nov 6, 2013 at 17:42

2 Answers 2

44

You can check with PowerShell:

[System.Text.Encoding]::Default

which even enables you to check that across several machines at once.

3

In .NET Core and .NET 5+ it is System.Text.Encoding.Default gives instance of UTF8. While .NET 4 and previous versions return Windows Active one. You can find more details on following: Microsoft Reference for Encoding

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .