remove non-UTF-8 characters from xml with declared encoding=utf-8 - Java

后端 未结 6 1567
再見小時候
再見小時候 2020-12-13 14:42

I have to handle this scenario in Java:

I\'m getting a request in XML form from a client with declared encoding=utf-8. Unfortunately it may contain not utf-8 charact

6条回答
  •  暖寄归人
    2020-12-13 15:39

    "test text".replaceAll("[^\\u0000-\\uFFFF]", "");
    

    This code removes all 4-byte utf8 chars from string.This can be needed for some purposes while doing Mysql innodb varchar entry

提交回复
热议问题