Hello,
I fooled around with this question a little more, trying to keep flexibility and increase speed. I would be glad to know how this compares to the other options. Shane, can you check this?
By the way, there is an error in Yvan's solution: if you set unID to id of unCarac
then unID isn't necessarily a number: if unCarac is a combined character, then unID will be a list of numbers (check ü). I tried to take that into account.
The second problem I met is that in
set inText to "Just a test." set outText to {} set theChars to every character in inText log theChars repeat with aChar in theChars copy aChar to the end of outText #copy character id (id of aChar) to the end of outText # copy (aChar as text) to the end of outText end repeat log outText log (outText as string) log (theChars as string) log (theChars = outText)
I get an empty string outText as a result: the aChar copied to the end of the list isn't a character anymore. theChars and the list outText look identical, but aren't. Is this a bug or a feature? Either of the commented versions works, though.
So if you want to have full control of the action and no additional software installed, I propose the following script. (I've included a timer which will only work if you have the Laptime.osax installed.)
set inText to "Ich möchte üben ohne mich zu ärgern!" set myTimer to start timer set outText to {} set outTextRef to a reference to outText set myLowers to "µßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ" set myUppers to "Μ,SS,À,Á,Â,Ã,Ä,Å,Æ,Ç,È,É,Ê,Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö,Ø,Ù,Ú,Û,Ü,Ý,Þ,Ÿ" # replace "SS" with "ẞ" if you want # This is based on ISO Latin 1 and can be expanded set theItemDelims to the text item delimiters set the text item delimiters to "," set myUppers to every text item of myUppers # just to make it easier to read set theChars to every character in inText # faster with longer texts repeat with aChar in theChars set aChar to aChar as text set myId to {} & (id of aChar) set myNum to item 1 of myId if myNum ≥ 97 and myNum ≤ 122 then set item 1 of myId to myNum - 32 set aChar to character id (myId) else if myNum ≥ 181 then set myNum to offset of aChar in myLowers if myNum ≠ 0 then set aChar to item myNum of myUppers end if copy aChar to the end of outTextRef # faster with longer texts end repeat set the text item delimiters to "" set outText to (outTextRef as text) set the text item delimiters to theItemDelims stop timer myTimer log the result outText
Am 28.01.2012 um 16:01 schrieb KOENIG Yvan: As long as the languages aren’t corrected, I will use :
set texte to "Hello happy tax payers" set texte2 to "" repeat with unCarac in text of texte set unID to id of unCarac if (unID > 47) and unID < 127 then set texte2 to texte2 & character id (65296 - 48 + unID) else set texte2 to texte2 & unCarac end if end repeat set the clipboard to texte2 & "ß"
|