简体   繁体   English

我想在 Java 中将奇怪的字符转换为正常字符

[英]I want to convert weird characters to normal in Java

I'm dealing with Java and I want to convert a String like this:我正在处理 Java,我想转换这样的字符串:

String = "SAYILI BU�DAYLI TARIM KREDİ KOOPERATİFİ"

to

SAYILI BUĞDAYLI TARIM KREDİ KOOPERATİFİ 

as output.作为输出。 How can I do that?我怎样才能做到这一点?

You have non printable characters in your input string您的输入字符串中有不可打印的字符

String str  = "SAYILI BU�DAYLI TARIM KREDİ KOOPERATİFİ";

Normalizer.normalize(str, Normalizer.Form.NFD);
str = str.replaceAll("[^\\x00-\\x7F]", "");
System.out.println(str);

This will remove the non printable characters from you string output string will be SAYILI BUDAYLI TARIM KRED KOOPERATF这将从您的字符串输出字符串中删除不可打印的字符将是SAYILI BUDAYLI TARIM KRED KOOPERATF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM