• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[B&S] about US-ASCII encoding

 
Jimmy Chen
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ASCII uses only the most significant 7 bits of an 8 bit word, the last is always 0.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • 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?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • 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
    • 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
    • Quote
    • Report post to moderator
    thanks Jeroen and Andrew very much!!!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic