views:

45

answers:

1

When I try to create a CultureInfo for zh-HK using the Windows Phone 7 RTM SDK, I get a System.ArgumentException with "Value does not fall within the expected range.".

This is using the ENU variant of the SDK (US / English).

http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(v=VS.95).aspx specifically uses the "zh-HK" identifier.

The exact code is:

var culture = new CultureInfo("zh-HK"); // Throws ArgumentException
+3  A: 

That MSDN document is specific to Silverlight 4. It doesn't state that all listed cultures are available on the phone. In fact:

During initial availability, Windows Phone 7 will support 5 languages; English, French, Italian, German and Spanish.

From http://windowsteamblog.com/windows_phone/b/windowsphone/archive/2010/07/13/windows-phone-7-getting-connected.aspx

I suspect that is why the Chinese (Hong Kong SAR, PRC) culture is not supported. There aren't even any Chinese region format settings on the device.
If you want to do something specific for phones that will be used in Hong Kong, I would recommend using CurrentCulutre or CurrentUICultre as appropriate.

Matt Lacey
Actually, at the bottom of that page it says
Blake Ramsdell
Actually, at the bottom of that page under "Version Information" it says "Silverlight for Windows Phone / Supported in: Windows Phone OS 7.0", so I'm not sure what docs page would be better. And the "zh-cn" CultureInfo works. But I think the answer here is "we have a docs page that's for a lot of different platforms, and the set of CultureInfo that we provide is not set in stone, and will vary from platform to platform."
Blake Ramsdell