[openbeos] Re: BString

  • From: "Marcus Overhagen" <dos4gw@xxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Mon, 12 Nov 2001 14:35:08 +0000

"Earl Colby Pottinger" <earlcp@xxxxxxxxxxx> wrote:

>Where in the BeBook does it say BStrings are for text only?
>If it is for text only, how will it handle UNICODE without zeros?

In BeOS, UTF-8 is used for UNICODE. This means there are
no zero bytes in the middle of strings, only the termination
is one zero byte.

>all the functions available in BStrings yourself.  That is what I did
>and it made my code a mess compared to the BString version which worked
>90% of the time but failed 10% because it is undocumented about how
>zero bytes affect BStrings.

No, it's not undocumented. BString is for storing strings, and a string
in C or C++ is always terminated by one zero byte. 
Bstring is only for "char *" strings, not for the "wchar_t *" ones!

If you have UTF-16 as input, this means the terminator is 
a wchar_t zero, and all other characters are wchar_t != 0
But this is not for use with the BString class.

To handle them, you could create a BWideString class,
or you simply convert them into UTF-8.


Other related posts: