
27 Sep
2007
27 Sep
'07
4:31 p.m.
Variable-width-encoded strings should be fairly straightforward when they are immutable, but will probably get hairy when they can be modified. True. I think the strings should be immutable. I think experience with Java and C# compared to C++ shows that an immutable string class is superior in most use cases
I also agree that immutable strings are the way forward for VWEs. If we had mutable strings consider how badly the following would perform: std::replace(utfString.begin(),utfString.end(),SingleByteChar,MultiByteChar); Although this looks O(n) at first glance, it's actually O(n^2), as the container has to expand itself for every replacement. I don't think a library should make writing worst case scenario type code that easy.