Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash AppleScript无法正确显示环境变量中的CJK字符_Bash_Variables_Syntax_Applescript_Osascript - Fatal编程技术网

Bash AppleScript无法正确显示环境变量中的CJK字符

Bash AppleScript无法正确显示环境变量中的CJK字符,bash,variables,syntax,applescript,osascript,Bash,Variables,Syntax,Applescript,Osascript,AppleScript处理脚本中的UTF-8字符没有问题。但它无法从环境变量中正确检索UTF-8字符 osascript-e'do shell脚本“echo”&你好"' 你好 你好=你好 osascript-e'do shell脚本“echo”&(系统属性“HELLO”)' ‰Ω†Ω 有什么建议可以解决这个问题吗?看起来系统属性不尊重shell环境的语言。呃,它们既古老又讨厌 这将为您提供正确的值: HELLO=你好 osascript -e 'do shell script "echo \

AppleScript处理脚本中的UTF-8字符没有问题。但它无法从环境变量中正确检索UTF-8字符

osascript-e'do shell脚本“echo”&你好"'

你好

你好=你好 osascript-e'do shell脚本“echo”&(系统属性“HELLO”)'

‰Ω†Ω


有什么建议可以解决这个问题吗?

看起来
系统属性
不尊重shell环境的
语言
。呃,它们既古老又讨厌

这将为您提供正确的值:

HELLO=你好 osascript -e 'do shell script "echo \"$HELLO\""'
# 你好

或者,通过AppleScript ObjC桥使用
NSUserDefaults
。几年前我写过很多;库的
环境变量
命令使用这种方法。

这在使用上是非常有限的,因为它只在与<代码> > shell脚本< /代码>。在使用<代码>系统属性< /代码>时,请考虑下面的工作;例如<代码> Hello=FO OSASScript -E >告诉应用程序“查找器”以显示对话框系统属性“hello”<代码>。但是在使用UTF8时它失败了;例如“代码> hello =你好 osascript-e'告诉应用程序“Finder”显示对话框系统属性“HELLO”
(即对话框显示
‰Ω†••Ω
)。因此,根据此答案,以下内容不起作用:
HELLO=你好 osascript-e'告诉应用程序“Finder”显示对话框“$HELLO\”
但是,在后续的
osascript
命令中使用之前,您可以将
do shell脚本
中的
echo
的结果设置为AppleScript变量。例如,以下命令正确显示
你好在对话框中:
HELLO=你好 osascript-e'设置envVar以执行shell脚本“echo\”$HELLO\“”-e'告诉应用程序“Finder”以显示对话框envVar'