• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Considering case...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Considering case...


  • Subject: Re: Considering case...
  • From: "koenig.yvan" <email@hidden>
  • Date: Sat, 22 Feb 2014 21:09:18 +0100

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




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Considering case... (From: Steve Thompson <email@hidden>)
 >Re: Considering case... (From: "koenig.yvan" <email@hidden>)

  • Prev by Date: Re: Considering case...
  • Next by Date: Re: Considering case...
  • Previous by thread: Re: Considering case...
  • Next by thread: Re: Considering case...
  • Index(es):
    • Date
    • Thread