AppleScript中的大小写敏感性

AppleScript中的大小写敏感性,applescript,case,case-sensitive,Applescript,Case,Case Sensitive,我有一个脚本,它可以将重音字符替换为它们的HTML等价物,这很好,但没有考虑字母的大小写敏感性。这引起了很多问题。我原以为重音字符可能一开始就不被认为是一种情况,但经过一些测试,我发现这不是问题所在,因为普通的非重音字母也会出现同样的问题。我已经试着添加考虑案例,但这并不能使它起作用。以下是一个示例: tell application "TextWrangler" copy the contents of the selection of window 1 to meinText

我有一个脚本,它可以将重音字符替换为它们的HTML等价物,这很好,但没有考虑字母的大小写敏感性。这引起了很多问题。我原以为重音字符可能一开始就不被认为是一种情况,但经过一些测试,我发现这不是问题所在,因为普通的非重音字母也会出现同样的问题。我已经试着添加考虑案例,但这并不能使它起作用。以下是一个示例:

   tell application "TextWrangler"

    copy the contents of the selection of window 1 to meinText

    set the contents of the selection of window 1 to asci2html(meinText) of me

end tell

on asci2html(derText)
    considering case
        tell application "TextWrangler"
            set derText to replace "Á" using "Á" searchingString derText
            set derText to replace "á" using "á" searchingString derText
            set derText to replace "A" using "BIG" searchingString derText
            set derText to replace "a" using "little" searchingString derText
            return derText
        end tell
    end considering
end asci2html
这将测试重音字符以及字母“A”,如果在以下字符上运行它,您将看到它不区分大小写:

a A. Á á


有什么想法吗?谢谢

我想我已经解决了这个问题,使用了我从macosxautomation.com改编的一些代码:

tell application "TextWrangler"
    set outputText to "nuthing"
    copy the contents of the selection of window 1 to meinText
    set the contents of the selection of window 1 to asci2html(meinText) of me
    return outputText
end tell


on replace_chars(this_text, search_string, replacement_string)
    considering case
        set AppleScript's text item delimiters to the search_string
        set the item_list to every text item of this_text
        set AppleScript's text item delimiters to the replacement_string
        set this_text to the item_list as string
        set AppleScript's text item delimiters to ""
        return this_text
    end considering
end replace_chars

on asci2html(derText)

    set the derText to replace_chars(derText, "a", "little")
    set the derText to replace_chars(derText, "A", "BIG")
    set outputText to derText

end asci2html
我确信它不是完全有效的:我在两个不同的变量之间反弹值,以避开一些我无法排除的错误,但它似乎无论如何都能工作,正如前后截图所示!有什么想法吗


考虑/忽略
只影响字符串比较。在这种情况下没有效果。好的,谢谢,这很有帮助。我尝试了另一个版本,该版本也进行了字符串比较(定义一个小写字母表,然后在选择替换之前检查其中是否包含我的字符),但我的derText变量包含整个字符串(当然不会出现在我的字母表中),而不是我正在清除的每个字符。似乎我需要让这个脚本分别运行它在比较/替换中遇到的每个角色。有关于如何做到这一点的快速指示吗?谢天谢地,这基本上就是我模拟出来的,但正如我所说,derText不是一个单独的角色,而是我正在清理的整个选择。如何让它为遇到的每个字符运行此命令?:考虑大小写将小写设置为“abcdefghijklmnopqrstuvwxyz”,如果小写包含derText,则使用“小”搜索字符串derText将derText设置为替换“a”,否则使用“大”搜索字符串derText end将derText设置为替换“a”