[英]matching word with special characters
I am using AndroidStudio for developing an app. 我正在使用AndroidStudio开发应用程序。 My App reads a text from the internet and AndroidStudio shows me the text (//)
我的应用程序从互联网读取文本,而AndroidStudio向我显示文本(//)
String mytext = getText(); // mytext = "unité"
I try to find a match with the word "unité", but I don't succeed. 我尝试找到与“unité”一词的匹配项,但没有成功。
when 什么时候
String wordToCompare = "unité"; // wordToCompare = "unité"
if (mytext.equals(wordToCompare)){
System.out.println("matched !");
}else{
System.out.println("no match !");
}
it will go to "no match !", because "unité" != "unité" 它将转到“ no match!”,因为“unité”!=“unité”
How can I set the String variable wordToCompare , so it will match ? 如何设置String变量wordToCompare,使其匹配?
I solved my problem by just switching the file to "ISO-8859-1". 我通过将文件切换为“ ISO-8859-1”解决了我的问题。
We can see the encoding-characterset in the bottom of AndroidStudio and there we can also switch to ohter charactersets. 我们可以在AndroidStudio的底部看到encoding-characterset,在那里我们还可以切换到其他字符集。 After switching AndroidStudio asks to reload or convert.
切换后,AndroidStudio要求重新加载或转换。 After converting the file is stored as "ISO-8859-1".
转换后,文件存储为“ ISO-8859-1”。
AndroidStudio will change the specific file and ".idea/encodings.xml". AndroidStudio将更改特定文件和“ .idea / encodings.xml”。
Now it works. 现在可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.