Differences between Japanese Number Formats

In .NET, I need (if possible) to distinguish between different types of Japanese number strings.

In Japanese numbers, numbers can be written in different ways, for example, for "1" there are characters "1" , "β…°" , "β… " , "β‘ " in half-width characters.

I need to compare strings like "MyString1" and "MyStringβ‘ " , and for obvious reasons they are not equal. I am wondering if there is a way to automatically change characters like "β‘ " to "1" automatically?

EDIT

I know that the obvious answer would be to make a list of all possible characters like "(" (their finite number) and replace them in the target line. But this is not a very β€œgood” way to get around this, in my opinion, and not very reliable ... therefore, if there is a general way, I would rather use this.

EDIT

Apologies, I wrote earlier that bot "β‘ " and "1" are considered numbers, but they are not. IsNumeric "β‘ " appears as false. Therefore, I think that in general there can be no way to switch from one to the other, except using direct substitution.

+4
source share
2 answers

fileformat.info tells me that marked numbers can be decomposed into regular numbers. Expressing this in ideone , it is shown that the normalization forms that will ensure that in .NET are KC or KD:

 var one = "β‘ "; Console.WriteLine(one); Console.WriteLine(one.Normalize(NormalizationForm.FormC)); // β‘  Console.WriteLine(one.Normalize(NormalizationForm.FormD)); // β‘  Console.WriteLine(one.Normalize(NormalizationForm.FormKC)); // 1 Console.WriteLine(one.Normalize(NormalizationForm.FormKD)); // 1 

However, there is a caution that normalizing the string may also distort other characters that you want to keep as they are.

+4
source

Well, playing with things, I found that I can convert "β‘ " to this numeric value ( "1" ) using Char.GetNumericValue() , which is pretty interesting because IsNumeric("β‘ ") appears as False .

And this also works for β€œβ…°β€ and β€œβ… β€ (not letters, but Japanese number format for β€œ1”)

It is a pity that I did not understand the cultural change ...

+1
source

Source: https://habr.com/ru/post/1469400/


All Articles