34

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?

Grodriguez
  • 495
  • 1
  • 5
  • 14
  • 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? – Hans Passant Nov 05 '13 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 Nov 06 '13 at 06:12
  • @Joey: Right. Unfortunately I have to read files which were generated by these ancient non-Unicode applications :-/ – Grodriguez Nov 06 '13 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 Nov 06 '13 at 17:42

2 Answers2

43

You can check with PowerShell:

[System.Text.Encoding]::Default

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

Joey
  • 40,002
  • 15
  • 104
  • 126
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

Imran Javed
  • 131
  • 3