"bstring"

Michel Fortin michel.fortin at michelf.com
Tue Apr 6 16:29:59 PDT 2010


On 2010-04-06 17:10:25 -0400, BCS <none at anon.com> said:

> Hello Ali,
> 
>> Justin Spahr-Summers wrote:
>> 
>>> 'string' to me represents a contiguous run of valid
>>> *characters* (i.e., the data has meaning and representation in and of
>>> itself)... not strictly enforced by D, of course, but that's how the
>>> type is used.
>> If by "character" you mean "code unit", yes.
>> 
>> string characters are UTF-8 code units in D and have meanings by
>> themselves only if they are one-byte UTF-8 sequences.
> 
> I think that's what the "not strictly enforced by D" part was about. 
> True or not, people often assume that a string is valid UTF-8 of some 
> kind.

It may not be strictly enforced, but std.range now iterates on code 
points instead of code units, making 'string' not very practical to use 
as a range when you need to iterate over UTF-8 code units (bytes), or 
with other text encodings. "bstring" is more appropriate for those 
cases.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list