On Monday, June 03, 2013 01:29:35 Jack Applegame wrote: > Jonathan, thanks for the detailed response. > > I think in D we should not use strings for storing "non text" > data. For such things we must use byte[] or ubyte[]. And ranges > will work as expected. Is it correct?
Exactly. If you want bytes, use ubyte[] or byte[] (probably ubyte[]). C++ lacks such a proper type (though C99 has uint8_t). char is specifically a UTF-8 code unit and should be treated as such. Also, if you have text that you _know_ is ASCII, then it's more efficient to cast the string to immutable(ubyte)[] and operate on it that way (so that it doesn't do any decoding). That's not currently handled by the string-specific functions (though the general array and range-based ones will handle it just fine), but I expect that that will change. - Jonathan M Davis
