File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Charset for 8-bit US ASCII ? (BETA) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Charset for 8-bit US ASCII ? (BETA)" Watch "Charset for 8-bit US ASCII ? (BETA)" New topic
Author

Charset for 8-bit US ASCII ? (BETA)

Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

For BETA exam
http://java.sun.com/j2se/1.4/docs/api/java/nio/charset/Charset.html
Just had some doubt as to what it was because the above document says that "US ASCII" is 7-bit ASCII. I'm inclined to use ISO-8859-1 because it's 8-bit
I think it is incorrect to use writeUTF because it prepends two bytes of length information before the string representation. To me, this will violate the data file format specification.


Junilu - [How to Ask Questions] [How to Answer Questions]
Tybon Wu
Ranch Hand

Joined: Jun 18, 2002
Posts: 84
US ASCII is correct. You cannot write 7 bits.


SCJP2
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

I take it back. writeUTF is appropriate to use for the header/schema information. I was just making it harder on myself than I needed to by explicitly writing the two-byte length info when the writeUTF takes care of this for me. :roll: I still think I can't use writeUTF with the data though because my requirements specify "no separators between fields, each field fixed length at maximum specified in schema...all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field."
[ October 03, 2002: Message edited by: Junilu Lacar ]
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5288
    
  10

Got word back from Sun about this. Max Habibi was right: there was a typo in the instructions and it should read "7-bit US ASCII" instead of "8-bit US ASCII".
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Charset for 8-bit US ASCII ? (BETA)