Inconsitency

Sönke Ludwig sludwig at outerproduct.org
Sun Oct 13 06:40:06 PDT 2013


Am 13.10.2013 15:25, schrieb nickles:
> Ok, if my understandig is wrong, how do YOU measure the length of a string?
> Do you always use count(), or is there an alternative?
>
>

The thing is that even count(), which gives you the number of *code 
points*, isn't necessarily what is desired - that is, the number of 
actual display characters. UTF is quite a complex beast and doing any 
operations on it _correctly_ generally requires a lot of care. If you 
need to do these kinds of operations, I would highly recommend to read 
up the basics of UTF and Unicode first (quick overview on Wikipedia: 
<http://en.wikipedia.org/wiki/Unicode#Mapping_and_encodings>).

arr.length is meant to be used in conjunction with array indexing and 
slicing (arr[...]) and its value is consistent for all string and array 
types for this purpose.


More information about the Digitalmars-d mailing list