Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.5: Use AppleScript to better work with Spaces' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Use AppleScript to better work with Spaces
Authored by: S Barman on Dec 26, '07 11:36:53AM
The various functions look interesting. However, I would change the last function to use "tr" instead of perl:

on make_lowercase(the_string)
   return do shell script "echo " & quoted form of the_string & " | /usr/bin/tr '[:upper:]' '[:lower:]'"
end make_lowercase
In the original script, you assume the character set locale to work with utf-8. Although utf-8 is more-or-less universal, it does have some problems with accented characters in non-English languages. The "tr" program respects current locale settings, which is more friendly to non-English character sets.

[ Reply to This | # ]
10.5: Use AppleScript to better work with Spaces
Authored by: jonn8n on Dec 26, '07 11:53:31AM
This is what I get in my testing:
{make_lowercase("JØnathan"), make_lowercase_alt("JØnathan")}
-->{"jønathan", "jØnathan"}

on make_lowercase(the_string)
	return do shell script "echo " & quoted form of the_string & " | /usr/bin/perl -pe 'use encoding utf8; s/(\\w)/\\L$1/gi'"
end make_lowercase


on make_lowercase_alt(the_string)
	return do shell script "echo " & quoted form of the_string & " | /usr/bin/tr '[:upper:]' '[:lower:]'"
end make_lowercase_alt

Jon

[ Reply to This | # ]