Unicode 6.0 has a new Indian Rupee Symbol, how do I get it?
Well you can't, not yet anyway. Unicode 6.0 adds the new Indian Rupee Symbol at U+20B9 (see https://www.unicode.org/charts/PDF/U20A0.pdf ) so how do you get it to work? Unfortunately you can’t get it to work immediately ;-(.
The problem’s actually really complicated as there are lots of moving parts. You need a font to display it, a keyboard to enter it, it might need to sort somewhere in a list, etc. However there is one piece that you can fix yourself on Vista/Windows7 and/or .Net 2.0-4.0. You can make a custom culture/locale using .Net’s CultureAndRegionInfoBuilder. It’s best to use the latest version of .Net to build custom cultures so that your custom culture includes the latest and greatest properties. If you use older versions, then Windows 7 and .Net v4 would be missing a few fields. Newer culture files should work on older machines.
Note that if you saved .Net currency data and expect to read it back with .Parse(), the symbol change might break your code. It’s way better to use Invariant or binary forms to store such data (see https://blogs.msdn.com/b/shawnste/archive/2005/04/05/405694.aspx ). So you might need to use caution when changing formats.
Anyway, this isn’t going to really help you at all, at least not immediately; without a font, you’ll just see square boxes. Sorry, I can’t help you with that, but if you do want to toy around with culture / locale data that uses the new U+20B9 code point, you can play with this sample.
As with everything, this code is as-is. I’ve already mentioned one way you could break your software, there could be others, like it’ll stomp on any existing custom cultures, so use it with caution. The .cs is attached. Save as rupee.cs, then from an elevated command line (press windows key, type cmd, then ctrl+shift+enter), add .Net 4.0 to your path, compile and run:
%windir%\Microsoft.NET\Framework\v4.0.30319\csc rupee.cs /r:sysglobl.dllrupee.exe
Also note that this doesn’t change your user override, you’ll have to change that with the Regional and Language Options control panel (intl.cpl). Then, congratulations, you now have square boxes for an Indian currency symbol ;-)
If you want to change for a different locale, just modify the appropriate spots in the file.
- Shawn
using System; using System.Globalization; class Rupee { static void Main() { CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures); foreach (CultureInfo culture in cultures) { RegionInfo region = new RegionInfo(culture.Name); if (region.TwoLetterISORegionName == "IN") { Console.WriteLine("Processing {0} : {1}", culture.Name, culture.EnglishName); CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder(culture.Name, CultureAndRegionModifiers.Replacement); NumberFormatInfo nfi = carib.NumberFormat; nfi.CurrencySymbol = "\x20B9"; carib.NumberFormat = nfi; try { CultureAndRegionInfoBuilder.Unregister(culture.Name); } catch { } carib.Register(); new CultureInfo("en-US").ClearCachedData(); } } cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures); foreach (CultureInfo culture in cultures) { RegionInfo region = new RegionInfo(culture.Name); if (region.TwoLetterISORegionName == "IN") { Console.WriteLine("Result {0} : {1}", culture.Name, culture.EnglishName); Console.WriteLine(" NFI Symbol {0}", culture.NumberFormat.CurrencySymbol); Console.WriteLine(" RI Symbol {0}", region.CurrencySymbol); Console.WriteLine(" ISO Symbol {0}", region.ISOCurrencySymbol); Console.WriteLine(" English {0}", region.CurrencyEnglishName); Console.WriteLine(" Native {0}", region.CurrencyNativeName); } } } }