• 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: Weird AppleScript Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird AppleScript Problem


  • Subject: Re: Weird AppleScript Problem
  • From: Thomas Fischer <email@hidden>
  • Date: Mon, 05 Dec 2011 11:03:36 +0100

Hello Bernardo,

I can't really answer your initial question, I suppose this depends on the definition of the character equality, and "ª" looks like "a" all right.

What is the best way to detect characters like these?

But if you want to reduce some text to the ascii roots, I would suggest a slightly different approach.
Since AppleScripts records are somewhat hard to reference, I have to to do this in a cumbersome way (perhaps somebody can point me to an easier and more efficient method).
The problems are:
  • I don't know a way to reference a value from a record using a variable instead of a fixed label.
  • I don't know how to reference an exterior record from within a script.
You might need to extend the table of characters to handle the missing ones (I should have a table for windows latin somewhere, probably for Mac Roman as well).
Actually there might be some OSAX somewhere to do this much faster, also Perl could do this very efficiently.
My script would look like this:

property myCharRecord : "{x170:\"a\", x186:\"o\", x192:\"A\", x193:\"A\", x194:\"A\", x195:\"A\", x196:\"A\", x199:\"C\", x200:\"E\", x201:\"E\", x202:\"E\", x203:\"E\", x205:\"I\", x210:\"O\", x211:\"O\", x212:\"O\", x213:\"O\", x214:\"O\", x217:\"U\", x218:\"U\", x219:\"U\", x220:\"U\", x224:\"a\", x225:\"a\", x226:\"a\", x227:\"a\", x228:\"a\", x231:\"c\", x232:\"e\", x233:\"e\", x234:\"e\", x235:\"e\", x236:\"i\", x237:\"i\", x238:\"i\", x239:\"i\", x242:\"o\", x243:\"o\", x244:\"o\", x245:\"o\", x246:\"o\", x249:\"u\", x250:\"u\", x251:\"u\", x252:\"u\"}"

set myText to "mÀbªÁz"  # or anything else
set newText to text2Ascii(myText)
return newText

on text2Ascii(myText)
set myLetters to every character in myText
set newLetters to {}
repeat with myLetter in myLetters
set myNumber to (id of myLetter)
if myNumber > 127 then
set myScript to "set myCharRecord to " & myCharRecord & return & ¬
"try" & return & ¬
"set myLetter to x" & myNumber & " of myCharRecord" & return & ¬
"on error" & return & ¬
"set myLetter to \"x" & myNumber & quote & return & ¬
"end try" & return
copy (run script myScript) to the end of newLetters
else
copy contents of myLetter to the end of newLetters
end if
end repeat
return newLetters as string
end text2Ascii


Best regards
Thomas


Am 04.12.2011 um 11:49 schrieb Bernardo Hoehl:

Hi friends,



I have found a problem with this code:

considering case
"ª" = "a"
end considering

On my understanding this should return "false".

But it returns "true".

What is the best way to detect characters like these?

I have been running a script for years, using the following code:

property forbidenList : every character of "ÁÂÄÀÃáâäàãÉÊËÈéêëèÍíîìïÓÔÖÒÕóôõöòÚÜÛÙúüûùçǺ"
property replaceList : every character of "AAAAAaaaaaEEEEeeeeIiiiiOOOOOoooooUUUUuuuucCo"


But this does not work for me when I have this special char.

Any shell script suggestions?

Thanks!



Bernardo Höhl
Rio de Janeiro

 _______________________________________________
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

  • Follow-Ups:
    • Re: Weird AppleScript Problem
      • From: Shane Stanley <email@hidden>
References: 
 >Weird AppleScript Problem (From: Bernardo Hoehl <email@hidden>)

  • Prev by Date: Re: Weird AppleScript Problem
  • Next by Date: Re: Weird AppleScript Problem
  • Previous by thread: Re: Weird AppleScript Problem
  • Next by thread: Re: Weird AppleScript Problem
  • Index(es):
    • Date
    • Thread