Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I retrieve string data from a database in Unicode format?

0
Posted

How can I retrieve string data from a database in Unicode format?

0

Location: http://www.jguru.com/faq/view.jsp?EID=285758 Created: Dec 26, 2000 Modified: 2000-12-26 02:14:24.367 Author: Joe Sam Shirah (http://www.jguru.com/guru/viewbio.jsp?EID=42100) Question originally posed by Jan Borchers (http://www.jguru.com/guru/viewbio.jsp?EID=48743 The data is already in Unicode when it arrives in your program. Conversion from and to the encoding/charset/CCSID in the database from/to Unicode in the program is part of the JDBC driver’s job. If, for some reason, you want to see the data in ‘\uHHHH’ format ( where ‘H’ is the hex value ), the following code, while not very efficient, should give you some ideas: public class UniFormat { public static void main( String[] args ) { char[] ac = args[0].toCharArray(); int iValue; String s = null; StringBuffer sb = new StringBuffer(); for( int ndx = 0; ndx < ac.length; ndx++ ) { iValue = ac[ndx]; if( iValue < 0x10 ) { s = "\\u000"; } else if( iValue < 0x100 ) { s = "\\u00"; } else if( iValue < 0x1000 ) { s = "\\u0"; } sb

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123