Cook Computing

Converting Locale ID (LCID) to Locale Name

February 4, 2009 Written by Charles Cook

While in the vicinity of System.Globalization, a quick tip, something I used the other day for the first time, on how to convert from a Locale ID, or LCID, to the corresponding locale name: just use the constructor of the CultureInfo class which takes an LCID:


CultureInfo ci = new CultureInfo(0x809);
Console.WriteLine(ci.Name);
Assert.AreEqual("en-GB", ci.Name);

And going the other way:


CultureInfo ci = new CultureInfo("en-GB");
Console.WriteLine("0x{0:X}", ci.LCID);
Assert.AreEqual(0x809, ci.LCID);