Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Code Page by Language-Culture?

Does anyone aware of C# API to accept Language-Culture and return corresponding Code Page? For instance, if I call

MagicClass.GetCodePage("ru-RU")

I would get

1251

If this was answered before, please drop me a link.

Thanks in advance.

like image 668
Yan Sklyarenko Avatar asked Jul 09 '10 14:07

Yan Sklyarenko


2 Answers

The TextInfo class (accessible via CultureInfo.TextInfo) contains code pages:

CultureInfo cultureInfo = CultureInfo.GetCultureInfo("ru-RU");
Console.WriteLine(cultureInfo.TextInfo.ANSICodePage); // 1251

It sounds like you want ANSI code pages, but you can also get Mac, OEM, and EBCDIC versions.

like image 175
Jeff Sternal Avatar answered Oct 23 '22 12:10

Jeff Sternal


new CultureInfo("ru-Ru").TextInfo.ANSICodePage

like image 23
Tim Lloyd Avatar answered Oct 23 '22 13:10

Tim Lloyd