Here is a piece of code which take care of non English characters. I know, mine is a bad one ;-)
my whichCase("À")
#=====
on whichCase(aChar) set maybe to my changecase(aChar, "upper") considering case set maybe to maybe = aChar end considering if maybe then display dialog "Character '" & aChar & "' is upper case" else display dialog "Character '" & aChar & "' is lower case" end if end whichCase
#===== (* Le second argument peut être: "upper", "lower", "title", "capitalize" *)
on changecase(txt, mode) set python_script to "import sys; print sys.argv[1].decode('utf8')." & mode & "().encode('utf8')" return do shell script "/usr/bin/python -c " & quoted form of python_script & " " & quoted form of txt end changecase
#=====
If you aren't reluctant to use a third party tool, you may use this alternate handler to convert to uppercase:
#===== (* Le second argument peut être: "upper", "lower", "title", "capitalize" *)
on changecase(txt, mode) tell application "ASObjC Runner" if mode is "upper" then return modify string txt so it is caps else if mode is "lower" then return modify string txt so it is lower else if mode is "capitalize" then return modify string txt so it is cap words end if end tell end changecase
#=====
The late one is my own choice because on my machine,ASObjC Runner is activated during the startup process.
Of course, it may be a good idea to embed the case converter code in the handler whichCase.
Yvan KOENIG (VALLAURIS, France) samedi 22 février 2014 21:07:30
|