Remove non-ASCII characters from String in Java

前端 未结 5 1307
渐次进展
渐次进展 2021-01-04 00:06

I have a URI that contains non-ASCII characters like :

http://www.abc.de/qq/qq.ww?MIval=typo3_bsl_int_Smtliste&p_smtbez=Schmalbl�ttrigeSomerzischeruchtanb

5条回答
  •  一个人的身影
    2021-01-04 00:23

    To remove the Non- ASCII characters from String, below code worked for me.

    String str="616043287409ÂÂÂÂ";
    
    str = str.replaceAll("[^\\p{ASCII}]", "");
    

    Output:

    616043287409
    

提交回复
热议问题