Re: Re. third-party dependencies
Re: Re. third-party dependencies
- Subject: Re: Re. third-party dependencies
- From: has <email@hidden>
- Date: Tue, 17 Mar 2009 19:38:22 +0000
Shane Stanley wrote:
Of course, proper unicode case changing is quite simply, HARD.
Looking into
it, the case mapping file is over a megabyte and there are numerous
rules
which need to be implemented.
Exactly. In an ASCII world native handlers were fine, but now this
looks
more like something for the language or a scripting addition. Which
is where
this discussion came in...
What Shane says. I wrote two text handling libraries for AppleMods,
and I wouldn't recommend them either. Even if the language had the
speed and power to write vanilla Unicode libraries, which it doesn't,
the amount of time and work needed to develop, test and debug those
libraries would be considerable. Given that all this functionality
already exists and has been extensively tested and optimised,
attempting to replicate it in AppleScript would be a huge make-work
exercise.
Calling into existing text manipulation libraries is the only sensible
way to do this. Given that any halfway decent engineer could easily
create an osax wrapper around the relevant C APIs in a couple of days,
I do sometimes wonder what Apple have been doing for the last fifteen
years. It's a trivial task with significant benefits to users; you
really couldn't ask for an easier ROI, even adding QA and
documentation time. Oh well.
In the meantime, while we're all waiting, don't forget that there are
at least two third-party options available: Satimage.osax and
TextCommands [1], both of which provide decent suites of basic text
manipulation features. And if you really must avoid third-party
dependencies and the performance cost of going through multiple
interpreters isn't a problem, you can always shell out to Perl,
Python, etc. For example:
on uppercase_text(txt)
set python_script to ¬
"import sys; print
sys.argv[1].decode('utf8').upper().encode('utf8')"
return do shell script "/usr/bin/python -c " & ¬
quoted form of python_script & " " & ¬
quoted form of txt
end uppercase_text
uppercase_text("Mon résumé est excellent!")
--> "MON RÉSUMÉ EST EXCELLENT!"
HTH
has
[1] Note that TextCommands commands which rely on pre-AS 2.0 strings
may not work correctly/at all under 10.5. Everything else should still
work fine, however, and it's open source if anyone feels like
providing a patch (I have no time to work on it myself).
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
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