[haiku-development] Re: BString method SymbolAt() proposal

  • From: Adrien Destugues <pulkomandy@xxxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 19 Jun 2010 14:03:06 +0200

Le 19/06/2010 13:54, Reinhard Scharnagl a écrit :
Introducing a BUnicodeString class would be an
alternative.
Not without having also a wide char kind of type.

I tried to propose a very simple BString extension for this moment.

Reinhard (Octopus)

Please be patient. Next week I'm starting another part of the Locale Kit work, and it's likely that some unicode string class may be part of it.

The problem with your proposition is that the "at" method would have to work on characters, not bytes. So you would have to look through the whole string to find all multi-byte characters to count properly. This is also why we have both CountChars and Length, the fist one being looping through the string to count, and the second one only returning the cached byte-length value.

Extending the existing BString would make it complicated to handle, because utf-8 isn't practical at all towork with. We will have to switch to an int32-based, utf-32 encoded string, with a way to convert to other encodings as needed.

--
Adrien.




Other related posts: