Parse a non-ascii (unicode) number-string as integer in .NET

前端 未结 3 1601
臣服心动
臣服心动 2021-02-20 06:49

I have a string containing a number in a non-ascii format e.g. unicode BENGALI DIGIT ONE (U+09E7) : \"১\"

How do I parse this as an integer in .NET?

3条回答
  •  被撕碎了的回忆
    2021-02-20 07:21

    It looks like this is not possible using built in functionality:

    The only Unicode digits that the .NET Framework parses as decimals are the ASCII digits 0 through 9, specified by the code values U+0030 through U+0039.

    ...

    The attempts to parse the Unicode code values for Fullwidth digits, Arabic-Indic digits, and Bengali digits fail and throw an exception.

    (emphasis mine)

    Very strange as CultureInfo("bn-BD").NumberFormat.NativeDigits does contain them.

提交回复
热议问题