How to compare Unicode characters that “look alike”?

前端 未结 10 1160
情歌与酒
情歌与酒 2020-11-27 10:42

I fall into a surprising issue.

I loaded a text file in my application and I have some logic which compares the value having µ.

And I realized that even if

10条回答
  •  旧时难觅i
    2020-11-27 11:39

    They both have different character codes: Refer this for more details

    Console.WriteLine((int)'μ');  //956
    Console.WriteLine((int)'µ');  //181
    

    Where, 1st one is:

    Display     Friendly Code   Decimal Code    Hex Code    Description
    ====================================================================
    μ           μ            μ          μ     Lowercase Mu
    µ           µ         µ          µ      micro sign Mu
    

    Image

提交回复
热议问题