1

I would like to convert an integer to Chinese numerals, I have tried the code below but all it outputs is the character "3" and not the Chinese equivalent. Can someone tell me if this is possible in c#?

    static void Main(string[] args)
    {
        CultureInfo ci = new CultureInfo("zh-CN", false);
        ci.NumberFormat.DigitSubstitution = DigitShapes.NativeNational;

        int value = 3;

        Console.WriteLine(string.Format(ci, "{0}", value));
    }

I've also tried it with value.ToString(ci), but get the same result.

Slicc
  • 3,217
  • 7
  • 35
  • 70
  • This should be a problem with the `Console` code page, take a look at this [so question](http://stackoverflow.com/questions/3780378/how-to-display-japanese-kanji-inside-a-cmd-window-under-windows). – Alessandro D'Andria Sep 26 '16 at 12:44
  • 1
    Check out the Microsoft documentation on DigitSubstitution: https://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.digitsubstitution(v=vs.110).aspx . It mentions that is reserved for future use and not currently used. – Jay Sep 26 '16 at 13:27
  • Also, check out the ci.NumberFormat.NativeDigits property. It contains an array of the Western 0-9 digits and their interpretation in the culture you defined. You will see that the array contains regular numbers. – Jay Sep 26 '16 at 14:55
  • Yes, I spotted the MS page regarding future use. Unfortunately I cannot find another mechanism to do the conversion. Apparently simple digit substitution doesn't work with Chinese as it is more complex that that. – Slicc Sep 27 '16 at 07:38
  • Regarding the font comment and console, if I put a break point and examine the output of string.Format(...) in debug it is still only showing "3" and not the Chinese equivalent. string abc = string.Format(ci, "{0}", value); abc = "3" – Slicc Sep 27 '16 at 07:41

0 Answers0