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

后端 未结 5 1121
庸人自扰
庸人自扰 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:22

    One isssue with Normalizer is that pre Java 1.6 its in sun.text package whereas in 1.6 its in java.text package and it method signature has changed. So if your application neeeds to run on both platforms you'll have to use reflection.

    An alternative custom solution is described as techniwue 3 here

提交回复
热议问题