Forums Register Login

8-bit US ASCII

+Pie Number of slices to send: Send
I almost finished 75% of the application.While reading the instructions document again the following sentance confused me :


The character encoding is 8 bit US ASCII.
Database schema



When converting string to bytes as the charset name "ASCII" and here is the code :

Such simple mistakes can cause to fail the assignment.In my code this statament throws a UnsupportedEncodingException.
I catch this exception an then throw a RunTime exception that indicates that the US-ASCII encoding is not supported.
What do you think??
+Pie Number of slices to send: Send
The encoding ASCII is a 7-bit encoding, namely, it just supports characters from 0-127.

My assignment says that I should use 8-bit encoding. Therefore I think you should revise this.

Go over the list of Supported Encodings.

I think the ISO-8859-X family are 8-bit encodings, as well as windows-1252
(aka Cp1252).

Now, you should use the encoding every time you read a bunch of bytes from the database and you want to convert them to a String, and also every time you want to convert a String into a bunch of bytes to write them back into the database.

If you use ASCII encoding you will only be able to represent as byte the first 128 characters, that is, you would be using just the first 7 bits of every character spectrum.

Whether you want to throw UnsupportedEncondingException or not is up to you and your design. In my case I absorb the exception and use the default encoding when this exception happens. However, I do that because when I try to create the database object I always check that the proposed encoding is supported using java.nio.charset.Charset.isSupported(String) method. Therefore I am not expecting this exception to happen here.
[ October 26, 2006: Message edited by: Edwin Dalorzo ]
+Pie Number of slices to send: Send
 

Originally posted by Khaled Mahmoud:
I almost finished 75% of the application.While reading the instructions document again the following sentance confused me :



When converting string to bytes as the charset name "ASCII" and here is the code :

Such simple mistakes can cause to fail the assignment.In my code this statament throws a UnsupportedEncodingException.
I catch this exception an then throw a RunTime exception that indicates that the US-ASCII encoding is not supported.
What do you think??



Hi Khaled,
The reason for the UnsupportedEncodingException is that the encoding type string you have entered is incorrect. The encoding string for Ascii is "US-ASCII" not "ASCII"
[ October 27, 2006: Message edited by: Mark Smyth ]
Just the other day, I was thinking ... about this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 855 times.
Similar Threads
NX:[URLyBird]Get the correct field values
writeUTF() and writeBytes()
Writting to the DB File - totally lost
8-bit US ASCII encoding???
NX: US-ASCII confusion
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:58:48.