Python returning the wrong length of string when using special characters

前端 未结 5 1350
庸人自扰
庸人自扰 2020-12-03 05:48

I have a string ë́aúlt that I want to get the length of a manipulate based on character positions and so on. The problem is that the first ë́ is being counted twice, or I gu

5条回答
  •  星月不相逢
    2020-12-03 06:14

    The best you can do is to use unicodedata.normalize() to decompose the character and then filter out the accents.

    Don't forget to use unicode and unicode literals in your code.

提交回复
热议问题