Forums Register Login

Java Utf-16 limitation.

+Pie Number of slices to send: Send
I was wondering how J2ee applications than need's to display Unicode text handle the Utf-16 limitation?
Is there anything new in Java 6?

Thank you
Sharon
+Pie Number of slices to send: Send
What is "the Utf-16 limitation"?
+Pie Number of slices to send: Send
java supports only UTF-16 strings.
+Pie Number of slices to send: Send
Are you imagining that UTF-16 only supports 16 bits worth (65536 max) of characters? If so, that is incorrect.

In a similar way to UTF-8, the thousands of additional characters are handled by escape codes, which introduce additional 16-bit words, to describe the extended characters. I forget exactly how it works, but go look at www.unicode.org.

In Java, one does sometimes have to take care, because some character-related methods report the number of 16-bit Java chars, rather than the number of Unicode characters. Again, I forget exactly how, but go look at the Java String API in detail.

Some code (particularly if it is old) might have trouble in some locales, if it assumes that the number of Java chars is the number of characters.
+Pie Number of slices to send: Send
The http://faq.javaranch.com/java/JavaIoFaq links to two blog articles on how to deal with characters beyond 16 bit.
+Pie Number of slices to send: Send
To be more precise, the question should be : how do large scale apps use web servers and yet support UTF-8.
Web servers : apache,web-logic,tomcat,jboos,ias etc.
Thank you
+Pie Number of slices to send: Send
Java supports many encodings, UTF-8 and ISO-8859 amongst them. If a program (web browser, database, ...) needs to get text in other encodings out of Java code, that's no problem at all. UTF-16 just happens to be the one in which strings are stored internally. (Come to think of it, I've never seen a web page served in UTF-16, or a database set up to use UTF-16, so if Java couldn't handle other encoding, that would be a major limitation.)
+Pie Number of slices to send: Send
 

if Java couldn't handle other encoding, that would be a major limitation.)



http://java.sun.com/docs/books/tutorial/i18n/text/convertintro.html
Java is unable to handle UTF-8,
IE can handle Utf-8 encoding, but when html form submitted, the web server internal convert the text to UTF-16, (request/response objects are java UTF-16 Strings)
+Pie Number of slices to send: Send
 

Originally posted by Sharon whipple:
Java is unable to handle UTF-8,


As already said above, that's not true. Just because Java stores characters in UTF-16 internally does not mean that Java is unable to handle UTF-8. The supported encodings page gives a list of character encodings that Java supports.
+Pie Number of slices to send: Send
Pure java String class is UTf-16
Web containers/servers build on java are unable to handle UTF-8

Is that correct?
+Pie Number of slices to send: Send
 

Web containers/servers build on java are unable to handle UTF-8

Is that correct?



As both Jesper and I have pointed out, no, that is not correct.
[ October 18, 2007: Message edited by: Ulf Dittmer ]
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3008 times.
Similar Threads
Jboss UTF-8 support
Internationalization
Unicode Character
Unicode CSV file.
"Contains" with UTF-8
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:40:06.