You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS下Automator调用Chrome打开含Unicode字符URL失败如何解决

AppleScript 调用Chrome打开含Unicode字符链接的兼容性问题解决

需求背景

通过Automator编写AppleScript,实现基于选中文本拼接链接并调用Chrome打开的功能,初始代码如下:

on run {input, parameters}
    set kanji to input as string
    set link to "https://jisho.org/search/" & kanji
    tell application "Google Chrome"
        open location link
    end tell
end run

问题表现

  • 输入文本为ASCII字符时运行正常,可正常拉起Chrome新标签页打开对应链接
  • 输入为日文汉字(例:漢字)等Unicode字符时无任何反应,添加try块捕获也没有报错
  • 相同逻辑调用Safari运行完全正常,属于Chrome兼容性问题

运行环境:Chrome 91.0.4472.164、macOS 11.3

修复后可运行代码

经调试后得到的正常运行版本代码如下:

on run {input, parameters}
    set kanji to input as string
    set link to "https://jisho.org/search/" & kanji
    try
        tell application "Google Chrome"
            tell its window 1
                set URL of (make new tab) to link
                end tell
        end tell
    on error errMsg number errorNumber
        display dialog "Error occurred:  " & errorNumber as text
    end try
end run

内容的提问来源于stack exchange,提问作者toby

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.11 23:03:00