← Back to context

Comment by CivBase

3 days ago

Bash, C strings, URL query strings, and CSVs off the top of my head.

C definitely does not represent null as a string.

  • No, but it also doesn't let you store null in a string variable.

    Well... it does, but that would just be an empty string.

    • In C, and many other languages at that, strings are just arrays of bytes.

      So you absolutely could store null in a string... It is even a valid ascii and UTF character. Now most string handling functions treat it as the end of a string in C but that is only by convention.

      How you would display null to a user is a different story all together but representing it in a string is not an unsolved programming problem, generally its when you need to actually display null that it becomes a hard problem because how do you display the absence of something, specifically when a space is not an absence.

      How do you serialise a string... Well it's already serialised given your specific endianness... So you just indicate that... This is 280 bytes of UTF8 data... It can contain as many nulls as you like, until you get 280 bytes of data you don't have all of it.

      1 reply →