From: Leslie Viljoen Date: 2006-06-15T18:43:59+09:00 Subject: Re: A plan for another unicode string hack On 6/15/06, Paul Battley wrote: > On 15/06/06, Yukihiro Matsumoto wrote: > > |I agree with Austin on this - the distinction is too vague. I'd leave > > |length and size the same and make a size_in_bytes method. > > > > On my latest prototype (not checked in anywhere), String#length and > > String#size behave same, and there is String#buffer_size to return > > size in bytes. The method name might change in the future. > > Actually, this makes a lot of sense. Why would you ever want to know > the actual byte length of a UTF-8 string? It's pretty meaningless for > most string-processing tasks: the main times you would need it would > be in allocation and interfacing with external systems and libraries. > Thus, something like buffer_size maps to real-world usage extremely > well, in my opinion. Of course the confusion here is caused by measurement units. Size in bytes or size in characters? Length and size don't (clearly) indictate that distinction, and neither does buffer_size. The name should indicate the unit so that you could immediately see that adding (eg.) length_in_characters to length_in_bytes would be in error. Here's some naming convention insight: http://www.joelonsoftware.com/articles/Wrong.html Les