我正在使用netbeans开发LWUIT项目以在Blackberry环境中运行。这个项目将从.net web服务中读取数据,我使用了ksoap2和Sax Parser。解析器看起来像那样
public static Vector ParseSAX(String input ,final String[] elements) {
final Vector values = new Vector();
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
DefaultHandler handler = new DefaultHandler() {
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
for(int u = 0;u < elements.length;u++){
if (qName.equalsIgnoreCase(elements[u].toString())) {
flag = true;
}
}
}
public void endElement(String uri, String localName,
String qName) throws SAXException {
}
public void characters(char ch[], int start, int length) throws SAXException {
if (flag) {
values.addElement(new String(ch, start, length));
flag = false;
}
}
};
InputStreamReader inputStream = new InputStreamReader(new ByteArrayInputStream(input.getBytes()), "UTF-8");
InputSource is = new InputSource();
is.setEncoding("UTF-8");
is.setCharacterStream(inputStream);
saxParser.parse(is, handler);
} catch (Exception e) {
e.printStackTrace();
}
return values;
}
我很关心解析阿拉伯字符。
顺便说一句,我将项目编码转换为UTF-8并在project.properties中更改了javac.encoding = UTF-8,在private.properties中我添加了runtime.encoding = UTF-8
如果我将此代码放在隔离的项目中,它运行正常。
如果我在BB项目或web项目中添加,会产生吗?
我不知道该怎么办?