Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Re: Learn a Variety of Languages . . . . . . .



>> > really ? - so how do you *easily* get a character count for a string of
>> > utf-8 bytes ?
>>
>> In PHP it's mb_strlen()  (with internal_encoding set to "UTF-8" of
>> course). You can still use strlen() to get number of bytes...
> 
> Thats my point - you need to use a whole set of seperate functions for
> string handling and regexs.

If you always want characters, never bytes, then always use mb_strlen().
It works with whatever the internal-encoding is set to.

You can also set mbstring.func_overload to have strlen() become an alias
for mb_strlen(), so you can continue to write strlen() everywhere. (It
will also then use multi-byte versions of the regex functions.)

Darren



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links