Funny, It Worked Last Time

... and other odd mutterings of a performance junkie

November, 2004

  • Funny, It Worked Last Time

    Encodings in Strings are Evil Things (Part 6)

    • 0 Comments
    How do you define operator[] for a string that's in a variable-width encoding such as UTF-8? One of the basic assumptions in std::string that I intend to honor is that operator[] returns a reference to the actual data, not a copy. For fixed-width encodings such as ASCII, UCS2, or UCS4, this is not a problem; I simply return a unsigned char/short/long. However, for variable-width encodings, I need to return a range of bytes, and presumably a size as well. I could do this with covariant return...
Page 1 of 1 (1 items)