Thursday, April 21, 2016

Blank Character is Not Null Character

Perhaps, it is partly because I'm not a native English speaker and partly because I forgot that the devil is in the details that I inadvertently wrote code that supposed to initialize a variable with blank characters with null characters.

Blank characters refer to whitespace character (https://en.wikipedia.org/wiki/Whitespace_character), not the null character (https://en.wikipedia.org/wiki/Null_character). In many cases, acceptable blank character for program input is space, which has a value of 20h in ASCII and 40h in EBCDIC. Well, this is not obvious for me at first until I'm debugging some code in an EBCDIC environment. 

So, next time you read an API documentation that says *BLANK*, it doesn't refer to NULL ('\0') character, but it refers to one of the whitespace character which in many cases refer to SPACE (' ').

As a bonus, these are some usable character conversion tables:
http://www.astrodigital.org/digital/ebcdic.html (this one explicitly states SPACE character as BLANK)

Post a Comment

No comments: