Safe ASCII char to replace whitespace before storing

Posted by AngryWhenHungry on Stack Overflow See other posts from Stack Overflow or by AngryWhenHungry
Published on 2010-06-14T11:48:22Z Indexed on 2010/06/14 11:52 UTC
Read the original article Hit count: 167

Filed under:
|

My code passes a big bunch of text data to a legacy lib, which is responsible for storing it. However, it tends to remove trailing whitespace. This is a problem when I read the data back. Since I cannot change the legacy code, I thought about replacing the all spaces with some uncommon ASCII character. When I read back the text, I can replace them back.

  1. Is this a bad idea, considering that I cannot touch the legacy storage code?
  2. Which character can I use as a substitute? I was considering some char upwards of 180.

There will only be spaces - no tabs or newlines - in the data. The data is alphanumeric, with special characters.

© Stack Overflow or respective owner

Related posts about ascii

Related posts about whitespace