[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] Updated code -- Change Case to Title Case
- From: Paul Merrell <marbux@...>
- Date: Thu, 13 Apr 2017 22:40:50 -0700
I have updated Duncan Cross's code for converting an English string to
title case, adapted it for use in NoteCase Pro, and posted it online.
Although the script now makes some calls to the NoteCase Pro API, the
names of those calls are sufficiently Hungarian that you will likely
have no problems adapting it to your particular need.
The adapted script:
* Fixes a bug in Duncan's original code that was a showstopper in Lua
5.2 and 5.3;
* Works around another bug in that code by converting the string to
all lower case before converting to Title Case (didn't work on string
of all upper case characters).
* Expands the list of words that should not be capitalized.
The script has a dependency, the pure Lua utf8 library by Xavier Wang,
namespaced as "utf8ex").  If you're not dealing with utf8 input you
can probably switch calls to that library, ("utf8ex.") with calls to
the equivalent Lua string library ("string.").
The code has been in heavy use for over 6 months without any new
My modifications to Duncan's code are deeded to the public domain.
I decided to post and announce this because: [i] I haven't found a way
to contact Duncan Cross to offer him my revisions; [i] debugging the
original code took quite a bit of work and other code weaknesses
remain; [ii] I put quite a bit of research and refinement into the
expanded list of words that should be lower-cased; and [iii] I want to
save others the work I put in on it; and [iv] perhaps someone wiser
than me can fix the above-mentioned bug and/or otherwise improve upon
what I've done.
Paul E. Merrell
[Notice not included in the above original message: The U.S. National
Security Agency neither confirms nor denies that it intercepted this