bug-libunistring
[Top][All Lists]
Advanced

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

[bug-libunistring] Script APIs


From: Simon Josefsson
Subject: [bug-libunistring] Script APIs
Date: Mon, 28 Mar 2011 21:56:48 +0200
User-agent: Gnus/5.110016 (No Gnus v0.16) Emacs/23.2 (gnu/linux)

Bruno,

This is just a small comment on interfaces, and I don't care strongly
about this.  I'm writing this mostly to give you an indication that
libunistring works so well that this minor issue has been the most
annoying thing I've experienced so far, which should speak plenty.

The APIs for finding out the script of a code point is this:

http://www.gnu.org/software/libunistring/manual/libunistring.html#Scripts

While they work fine, they are a bit cumbersome to use compared to (for
example) the joiningtype and combining class functions.  My concern is
that there aren't any enum's for the various scripts, so my code ends up
looking like this:

    case 0x30FB:
      {
        /* KATAKANA MIDDLE DOT */
        size_t i;
        bool script_ok = false;

        for (i = 0; !script_ok && i < llen; i++)
          if (strcmp (uc_script (label[i])->name, "Hiragana") == 0
              || strcmp (uc_script (label[i])->name, "Katakana") == 0
              || strcmp (uc_script (label[i])->name, "Han") == 0)
            script_ok = true;

        if (script_ok)
          return IDN2_OK;
        return IDN2_CONTEXTO;
        break;
      }

While my code certainly could be optimized, I think the fundamental
issue is the use of strings for describing scripts.

Or is there any particular reason there an enum for each script isn't
used?  Like what is used for joining types and combining classes (for
example).

/Simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]