Convert Unicode to ASCII without changing the string length (in Java)

后端 未结 5 1101
庸人自扰
庸人自扰 2020-12-01 16:58

What is the best way to convert a string from Unicode to ASCII without changing it\'s length (that is very important in my case)? Also the characters without any conversion

5条回答
  •  庸人自扰
    2020-12-01 17:31

    Use java.text.Normalizer.normalize() with Normalizer.Form.NFD, then filter out the non-ASCII characters.

提交回复
热议问题