在我的
java程序中,我正在从xml中检索一些数据.这个xml只有很少的国际字符,用utf8编码.现在我使用xml解析器读取这个xml.一旦我从xml解析器中检索特定的国际字符串,我需要将它与预定义的字符串集进行比较.问题是当我在国际字符串比较中使用string.equals失败时.
如何在java中将字符串与国际字符串进行比较?我正在使用SAXParser& XMLReader从xml读取字符串.
这是比较字符串的行
String country;
country = getXMLNodeString();
if(country.equals("Côte d'Ivoire"))
{
}
getXMLNodeString()
{
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
XmlParser xmlParser = new XmlParser(); //my class to parse xml
xr.setContentHandler(xmlParser);
/* Parse the xml-data from our URL. */
xr.parse(new InputSource(url.openStream()));
/* Parsing has finished. */
//return string here
}