• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Padding of the field value before writing it in the database.

 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
before writing the byte array in the database i pad it with null characters:


But after this updated value is displayed, instead of the empty spaces I see only the small rectangles.
(sorry, I don't know how this small rectangles are called in English)

if I change padding character to :


The updated record has the empty spaces, no "small rectangles" and looks good.

Could you explain me why I see this small rectangles when i use null-value?
Should i use the second one with (byte)32 ?
The empty spaces of the original values from the SUN's db file are filled with 32.
Thanks a lot for your help!
Olena
[ April 18, 2005: Message edited by: Olena Golub ]
 
Wei-ju Wu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the Swing components seem to render several non-printable characters as little squares. The same happens if you choose a character like \n (Newline) where you would instead the component to display as multiline. It depends on your specification how you handle your file. My specification says that strings should be null-terminated if they are shorter than the field length, but the file that comes with the assignment pad the fields with space characters (ASCII 0x20 or 32). I personally chose to pad the fields with null values in the functions that write to the file according to the specification. To handle the delivered file, my reading functions accept both possibilities, space padded and null terminated.

Wei-ju
 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wei-ju, thanks a lot for your help!

Originally posted by Wei-ju Wu:
To handle the delivered file, my reading functions accept both possibilities, space padded and null terminated.

Wei-ju


do you make something like this:


?

Thanks a lot!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic