• 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

[B&S] about US-ASCII encoding

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm just confused about the character encoding.

As the scjd assigment says:
"The character encoding is 8 bit US ASCII."

But when I checked the jdk API, US-ASCII encoding is described as :
"US-ASCII Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set".

so is it 8 bit or 7 bit?

actually I used the "US-ASCII" to read the db file schema, it's correct. Just confused.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another question, assigment says:
"All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field."

Is it mean all fields' lengths are fixed and "nll"s fill all the rest of the "empty" length. Or, just only one "null" is put at the end of the text and rest length is trimmed?

thanks! hope you can understand my poor English
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ASCII uses only the most significant 7 bits of an 8 bit word, the last is always 0.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen T Wenting:
ASCII uses only the most significant 7 bits of an 8 bit word, the last is always 0.



I think I can guess your generation now, Jeroen, 8 bit words - PDP 8 days?
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nova,

assigment says:
"All text values, and all fields (which are text only), ... null terminated if less than the maximum length for the field."

Is it mean all fields' lengths are fixed and "nll"s fill all the rest of the "empty" length. Or, just only one "null" is put at the end of the text and rest length is trimmed?

  • All fields are fixed length - you should be able to see this when you read the file.


  • Having the fields (and thus the records) fixed length opens up possibilites of using APIs other than DataInputStream and DataOutputStream. But that is something that can (and should) be discussed in another topic if you are interested.

  • As for the nulls in the physical file / padding, you should look at what is currently being used as padding in your provided data file.


  • You might also be interested in reading this response from Sun.

    hope you can understand my poor English

    No problems, your English is fine.

    Regards, Andrew
     
    Jeroen T Wenting
    Ranch Hand
    Posts: 1847
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Barry Gaunt:


    I think I can guess your generation now, Jeroen, 8 bit words - PDP 8 days?



    not that old, but I learned programming on a VAX that used a bank of Philips V2000 VCRs for tapestreamers.
     
    Jimmy Chen
    Ranch Hand
    Posts: 54
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thanks Jeroen and Andrew very much!!!
     
    reply
      Bookmark Topic Watch Topic
    • New Topic