• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

8-bit US ASCII

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic