3 ms·
> You deal with strings as bytes (opaque data) (edit2: didn't really mean bytes here. see child comments) more often than strings as text in systems programming
by throwawayish 10y ago
> You deal with strings as bytes (opaque data) (edit2: didn't really mean bytes here. see child comments) more often than strings as text in systems programming, basically.
That's true in some sense [1] for unix-ish OSes, but doesn't hold on other operating systems.
[1] Even on unix-ish OSes it's pretty obvious that filenames are supposed to be encoded in something and aren't just uint8_t*. There's just no one telling you what that encoding is, so normally it's guessed (eg. $LANG). For filesystems that actually have a defined encoding (eg. NTFS\Win32, JFS, HFS+, APFS and the whole bunch of "non-unix OS FS") these are re-coded by the filesystem driver in the unix-ish OS. Eg. ntfs-3g transcodes filenames to UTF-8; cifs takes a "iocharset" option; and we of course have convmv(1).
The idea that "file names and generally everything in the OS is a bunch of bytes" is pretty much only shared by unix-ish systems.
- Manishearth 10y agoOh, that's not the sense in which I was using the term "bytes". Rust has different string types for file contents and path names, with their own (platform-dependent) restrictions.