Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null terminated string

 
Thirumurugan Mylrajan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I hava basic question. The following is a req.

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. The character encoding is 8 bit US ASCII.

What is the meaning of "Null terminated" here. I see in the DB file that they provided have 0x32 after the values.

Should I end every string with a special character?.

Thanks.
 
Thirumurugan Mylrajan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, the fields are followed by 32 and not 0x32 as mentioned above.

Thanks.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it means that either the description of the file format as stated in the documentation is incorrect or you (and everybody else) have been supplied with a corrupt file.

The general consensus is (and I believe there's an old post confirming this by someone who asked Sun about it and actually got a reply) that the description in the assignment documentation is incorrect and in fact the data is padded with spaces instead of null values.

I've just mentioned that in my choices.txt, using a realworld situation in which something similar happened (file format specs as supplied by customer didn't match supplied test data, customer wanted us to go from the supplied data rather than the documentation) as justification.
 
Thirumurugan Mylrajan
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the clarification.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11888
203
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeroen T Wenting:
The general consensus is (and I believe there's an old post confirming this by someone who asked Sun about it and actually got a reply)...


FYI, I think the post Jeroen mentioned is this one.

Regards, Andrew
 
Josephx Rainerd
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

My B&S assignment datafile, has values padded with space though ,mentioned in spec, that length < max length needs to be null terminated.


I (so far) took the approach of padding with spaces)(ignoring spec and documenting the reason).

In my search screen, I return
'Fred' matches 'Freddy'
'Fred' DOES NOT match 'Freddy' for exact search
BUT 'Fred' matches 'Fred ' space padded for exact search

I do not see any way of distinguishing 'Fred' and 'Fred ' .

Is that going to upset Sun?

Also I let empty field (unless exact search) match all data. So all blank fields, in effect return all records.( I have a GUI element in screen) to chose 'Show all' also ).

Thanks
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, since the spaces are padding.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic