问题描述:

Say I want my programs to work correctly on anyone's computer in the world.

I have no clue how much work this takes but I figure it's easier to get right with a console app so I started by decompiling MSTest.exe entry point and found:

private static void SetUICulture()

{

Thread.CurrentThread.CurrentUICulture =

CultureInfo.CurrentUICulture.GetConsoleFallbackUICulture();

if (

(

(Console.OutputEncoding.CodePage != 0xfde9) &&

(Console.OutputEncoding.CodePage !=

Thread.CurrentThread.CurrentUICulture.TextInfo.OEMCodePage)

) &&

(Console.OutputEncoding.CodePage !=

Thread.CurrentThread.CurrentUICulture.TextInfo.ANSICodePage)

)

{

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

}

}

It looks like the intention here to look at the "fallback" culture, and then look at some conditions that would prevent it from being "good enough" and if so set it to us english.

What is is the 0xfde9 doing?

Does this effectively internationalize a console app?

网友答案:

The 0xfde9 code page is UTF-8. So the code says, if the code page is not UTF8, OEM, or ANSI, then set the culture to US English.

Now, your application should work correctly assuming the presence of the version of the .Net Framework your application requires, but the issue is whether or not the end user will be able to understand what your application is trying to tell them.

相关阅读:
Top