Mailing List Archive


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

Re: Learn a Variety of Languages . . . . . . . (was: Re: [tlug] Re: Bourne Shell is the most appropriate scripting language)



On Thu, 18 Jan 2007, Ian MacLean wrote:

     class String
        def utf8_char_count
            split('').select { |c| c[0] < 128 }.length
        end
     end

am I missing somthing - doesn't this just count all the ascii chars in your string ?

In UTF-8, all characters contain exactly one byte without the high bit set.

You can easily look up on the web how the encoding works.

However, Zev's solution is probably better. :-)

cjs
--
Curt Sampson       <cjs@example.com>        +81 90 7737 2974


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links