使用 AppleScript 将韩语字符从 Excel 复制到 TextEdit

发布于 2024-10-12 08:36:43 字数 683 浏览 2 评论 0原文

我有一个 Excel 电子表格,其中包含韩文字符,编码方式不知道是什么——我假设它是 UTF-8,因为我可以将其复制并粘贴到 vim 或 textedit 或其他任何文件中。然后我可以将这些字符插入到我知道是 UTF-8 并且有效的数据库中 也很好。

但是,当我运行以下可能执行相同操作的 AppleScript 时,我将所有韩文字符替换为字母“a”。使用 AppleScript 复制或粘贴时有没有办法强制编码?我还缺少其他东西吗?

韩语示例单元格: Been메일 주소。
TextEdit 中的相同输出:aaa aa

tell application "Microsoft Excel"
       activate
       open (choose file)
       activate object sheet "Sheet1"
       copy range range "A1:G1000" of active sheet
end tell

tell application "TextEdit"
       activate
       open (choose file)
       tell application "System Events"
               keystroke (the clipboard)
       end tell
end tell

I have an Excel spreadsheet which contains Korean characters in who-knows-what encoding -- I'm assuming it's UTF-8 since I can copy and paste it into vim or textedit or whatever just fine. I can then insert those characters into a database I know is UTF-8 and that works
just fine too.

However, when I run the following AppleScript that presumably does the same thing, I get all the Korean characters replaced by the letter "a". Is there a way to force an encoding when copying or pasting with AppleScript? Am I missing something else?

Example cell in Korean: 이메일 주소.
Same output in TextEdit: aaa aa

tell application "Microsoft Excel"
       activate
       open (choose file)
       activate object sheet "Sheet1"
       copy range range "A1:G1000" of active sheet
end tell

tell application "TextEdit"
       activate
       open (choose file)
       tell application "System Events"
               keystroke (the clipboard)
       end tell
end tell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只想待在家 2024-10-19 08:36:43

既然你正在复制和粘贴,为什么不直接这样做呢?您在 Excel 中复制,因此在 TextEdit 中只需使用此...

tell application "System Events"
    keystroke "v" using command down
end tell

Since you are copying and pasting, why not just do that. You copy in excel so in TextEdit just use this...

tell application "System Events"
    keystroke "v" using command down
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文