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

Re: Postel's law, exceptions


Re:  Postel's law
John Cowan wrote:

>Amelia A Lewis scripsit:
>
>  
>
>>It was an interesting argument.  I found myself in the position of
>>arguing that *all* character streams in Java have encodings (including
>>java.lang.String).  The counter to this is a filter stream, such as a
>>TeeWriter (I was arguing that the problem was that Java did not provide
>>a getEncoding() method on all streams).
>>    
>>
>
>I think you have a hold of the right stick, but at the wrong end.
>Byte streams have encodings if they represent text, but at the level of
>character streams, encodings have been abstracted away.
>
>  
>
They have *almost* been abstracted away: a Java "character" is UTF-16.  
Some Unicode
characters require more than one Java "character" to represent then.  
All *implementations*
of characters have one (or more) underlying encoding.  A nominal 
getEncoding() method
on a Java 1.n character stream even TeeWriter should always produce 
"UTF-16".

This should upset no-one, because some real characters may require more 
than one
Unicode "character" to represent them, anyway.  Take Vietnamese, please: 
if I have
a u with a horn accent above plus a dot underneath [1], that is one real 
character
(according to what people think of as characters) but three Unicode 
characters,
3 UTF-16 characters, 6 bytes of storage. 

It is just a fact of life that there are edge cases that are not neat to 
represent. The only
way that software will adequately support "edge cases" (which is a 
euphemism for
writing systems of economically unimportant nations, to some extent) is  
for
libraries to support it: take it out of the hands of Joe Programmer and 
let the
API writers do it. XML's spin on simplicity (that Joe Programmer can fairly
easily write a minimal parser) sets wrong expectations: that anything that
is not in a minimal parser is part of the conspiracy of fluff.

We are all taught about shorts, longs, doubles and floats at University 
(if we
studied programming), and the idea that numbers exist in different encodings
which each have different properties is no surprise to anyone (except 
perhaps
LISPers with BIGNUMS).  That strings also exist in different encodings
with different properties should also be taught.

Cheers
Rick Jelliffe

[1] accepting for argument's sake 
http://leb.net/archives/reader/csi/0352.html


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.