views:

17

answers:

2

Hello Community!

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.

+1  A: 

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

chibacity
Thanks! +1 to your answer as it is correct as well! :)
Yan Sklyarenko
+3  A: 

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.

Jeff Sternal
Thanks! Accepting your answer as it is correct and exhaustive!
Yan Sklyarenko