[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Java/Unicode brain damage

  • From: Miles Sabin <msabin@i...>
  • To: xml-dev@l...
  • Date: Thu, 26 Jul 2001 22:59:46 +0100

java unicode
Benjamin Franz wrote,
> Miles Sabin wrote,
> > [snip: answering the wrong question]
>
> I'm being dense today. When you say 'UTF-16 units' do you mean that
> in Java a single character in the surrogate ranges may consist of 
> (correctly IMHO) a _complete_ 32-bit surrogate pair or (dain 
> bramagedly) of the individual 'halfs' of the pair (thus making a 
> single character into two individual 'units' of 16-bits each)? If 
> the latter, the Java's handling of Unicode is broken-as-designed and 
> must be fixed (most likely via deprecation of the existing String in 
> favor of a completely new string type for the sake of backwards 
> compatibility with already deployed apps).

A Java 'char' is a 16 bit data type, so it simply isn't possible for
it to directly represent a Unicode character. There's no way of
changing that, so treating them as representing UTF-16 units seems to
be the best option. So, yes, a Java char might represent one half of
a surrogate pair. Whether that's brain damaged or not is likely to
be point of view dependent. But it's not a broken representation of 
Unicode characters ... it _isn't_ a representation of Unicode
characters.

That does leave the String class dangling tho'. As it stands all its
method and constructor signatures are defined in terms of chars, and
those can't be changed without breaking almost all the Java code in
existence ... and for that same reason deprecation doesn't seem very
likely either. It might be possible to retrofit character oriented 
methods, but it'd probably be a better option to create a completely 
new class. There's nothing to stop anyone from doing that, tho' it
wouldn't hurt if interested parties took a proposal to the JCP.

Cheers,


Miles

-- 
Miles Sabin                                     InterX
Internet Systems Architect                      27 Great West Road
+44 (0)20 8817 4030                             Middx, TW8 9AS, UK
msabin@i...                               http://www.interx.com/


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.