Problem in displaying Vietnamese Unicode characters after parsed using XML Xerces.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ardhi_Gun
Posted On:   Wednesday, August 28, 2002 01:59 AM

Does someone has experienced in parsing Vietnamese XML and then display the data in JSP? I've tried using this method with Xerces: String st; public void characters(char[] ch, int start, int length) { String stb = new String(ch, start, length); try { byte[] utf8 = stb.getBytes("UTF8"); st = new String(utf8); } catch (UnsupportedEncodingException e) {} } and then display in JSP using this: out.println(st); It always displayed some character corrupted as a box or as ? . I've checked at www.unicode.org, Vietnamese is supported. I need to display:    More>>

Does someone has experienced in parsing Vietnamese XML and then display the data in JSP?

			
I've tried using this method with Xerces:
String st;
public void characters(char[] ch, int start, int length)
{ String stb = new String(ch, start, length);
try
{ byte[] utf8 = stb.getBytes("UTF8");
st = new String(utf8);
}
catch (UnsupportedEncodingException e)
{}
}




and then display in JSP using this:

			
out.println(st);



It always displayed some character corrupted as a box or as ? .
I've checked at www.unicode.org, Vietnamese is supported.



I need to display:
Tên người sử dụng
but always display as:
Tên ngu?i s? d?ng

Please someone tell me, where did I go wrong?

thanks    <<Less

Re: Problem in displaying Vietnamese Unicode characters after parsed using XML Xerces.

Posted By:   eimi_nos  
Posted On:   Monday, September 9, 2002 04:48 AM

Given that you have unicode characters as elements of char[] ch, and out is UTF8 compatible, you can simply test this:

static void characters(char[] ch){
try{
StringBuffer buffer= new StringBuffer();
for(int i=0;i buffer.append((char)ch[i]);
}
out.println(buffer.toString());
}catch (IOException ioe){ioe.printStackTrace();}
}
About | Sitemap | Contact