jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: slang: UTF-8 and strlen


On Sun, May 11, 2003 at 01:27:37PM -0400, John E. Davis wrote:
...
>  I propose the following for slang v2:
> 
>   strlen: returns the number of characters (not bytes!) in a string.
>           Any combining characters will not be included in the sum.
> 
> In addition, I propose two new functions:
> 
>   strbytelen: Returns the number of bytes in a string.
> 
>   strcharlen: Returns the number of chars in a string, counting the
>               combining characters.
> 
> Comments about this proposal?

How about an optional argument for the counting method, e.g.

 Integer = strlen(str, count=1)
 
with count == 0 return bytes
     count == 1 return characters skip "dead" characters
     count == 2 return chars counting "dead" chars

Sometimes, you want to switch the behaviour at runtime, based on some value
and 
 len = strlen(str, foo)
is simpler than
 if (foo)
   len = strlen(str)
 else
   len = strcharlen(str)  

So if this is not too much effort, I'd prefere this one.

Günter


-- 
Milde at ife.et.tu-dresden.de

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]