[openbeos] Re: BString

  • From: "Erik Jakowatz" <erik@xxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Mon, 12 Nov 2001 19:29:58 -0800

>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?

To quote The Book:

"Currently, BString only supports assignment and retrieval of strings 
that contain single-byte characters. If you want to use BString to store 
a string that contains multi-byte (UTF8) characters, you have to flatten 
the string yourself and adjust the character count arguments 

Not sure what is meant by "flatten the string", but given this statement 
plus the fact that *only* UTF-8 is mentioned leads me to think that 
BString should be thought of as *not* supporting NULL characters 
anywhere in the data.  Certainly, there is no place where the docs 
explicitely state that "BStrings are for text only", but I think it's 
reasonable to assume that the authors were implicitely acting as though 
they were -- I don't think I've ever heard of the terminology "string" 
used to describe anything other than text data.

>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.

I think it's undocumented because the class wasn't intended to deal with 
NULL characters randomly embedded in the text data.  Seems to me that 
BString is intended to be a light-weight string class that provides the 
most common string operations, and not an end-all-be-all solution like 
basic_string attempts to be.

Not looking to open a debate on basic_string, ;)


Data is not information, and information is not knowledge: knowledge is 
not understanding, and understanding is not wisdom.
        - Philip Adams

Other related posts: