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

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 19 Jun 2010 12:58:42 +0200

Reinhard Scharnagl <rescharn@xxxxxxx> wrote:
> Thus the most important first extension of BString class should be to
> have it provide a method to return a BString containing exactly one 
> single
> UTF8 symbol (up to several bytes) at a given index: 
> 
> BString SymbolAt(int32) index const; 
> 
> ( or worse:  BString CharAt(int32) index const; )
> 
> Its Length() might vary >= 1, but its CountChars() always has to 
> return 1;
> 
> ( You see, the established name for CountChars() has not been chosen 
> very intuitively and should have been better named CountSymbols(). )

For one, CharAt() is a much better name in my opinion than SymbolAt(), 
same for CountChars() vs. CountSymbols() - UTF-8 characters aren't 
automatically symbols, and what you are interested in here are 
characters, not symbols.

Anyway, I think a method that returns a Unicode character, not a UTF-8 
byte array, would be more appropriate. There is much for functionality 
in this regard that would be desirable, though.
Also, if you plan to work on anything like that, see 
headers/private/interface/utf8_functions.h - that one should already 
have everything you should need.

Bye,
   Axel.


Other related posts: