Here's a little script I wrote to test the function:
Code: Select all
on mouseUp
put textToEntities(fld "testIn") into fld "testOut"
end mouseUp
function textToEntities textToCheck
put "&,ä,á,à,â,ã,æ,å,ë,è,é,ê,í,ï,î,ñ,ö,ó,ò,ô,õ,ü,ú,ù,ç,Å,Â,Æ,Ö,Ü,—,£,¡" into textTable
put "&,ä,á,à,â,ã,æ,å,ë,è,é,ê,í,ï,î,ñ,ö,ó,ò,ô,õ,ü,ú,ù,ç,Å,Â,Æ,Ö,Ü,—,£,¡" into entityTable
put 0 into itemCount
repeat for each item textTableItem in textTable
get textTableItem
add 1 to itemCount
replace it with item itemCount of entityTable in textToCheck
end repeat
return textToCheck
end textToEntities
This works fine for lower-case special characters: å â æ are correctly converted to å â æ for example.
But upper-cases are incorrectly converted to their lower-case equivalents: Å Â Æ go to å â æ and Ö Ü to ö ü (instead of Å Â: Æ and Ö Ü respectively).
What am I doing wrongly?