On Mon, 3 Jul 2000, Markus Kuhn wrote:
> > is there such a compact function already available for toupper and 
> > tolower (and perhaps totitle) mapping? ...
> 
> I don't know of any, but here is how I would implement it: Cut the Unicode
> space into intervals x..y ...
> Then search for c in a binary-search the matching stored interval and
> evaluate toupper(c) and tolower(c) as above...

As noted in the Unicode spec, it is almost always faster (at a fairly
small cost in storage) to do a two-level table, indexing into a table on
the first byte to get a pointer to a secondary table indexed by the second
byte.  With careful table generation, this can exploit the internal
structure of the code space about as well -- many of the pointers in the
first table point to the same few secondary tables -- and the test is much
quicker and simpler.

This won't work for unusual applications where minimizing table space is
utterly crucial, but it's the best general-purpose solution. 

                                                          Henry Spencer
                                                       [EMAIL PROTECTED]

-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/lists/

Reply via email to