cshift-jis

Can Shift-JIS contain zeros?


I am having to store sequences of Japanese names written in the Shift-JIS format that are scooped from the internet. I am thinking for storing them in character arrays and writing them to a file with something like:

fprintf(fp,"The name is [%s]\n",string_array);

My only concern is that if Shift-JIS characters may include '\0' then this will obviously break... but I'm not sure if Shift-JIS ever does. Unfortunately it seems Shift-JIS is such an arcane system that I can barely comprehend the definitions of the system I've found online with enough confidence to answer the question myself.


Solution

  • Looking at Wikipedia's Shift-JIS byte map, the byte values 0x00-0x3F are not used as second bytes (and nor are 0x7F or 0xFD-0xFF), so you're fine interpreting '\0' as a null terminator.