使用批处理打开包含元音变音的 URL [英] Open URL that contains umlaut with batch
问题描述
我想用批处理文件在 chrome 中打开一个 URL.这适用于普通网址,但不适用于带有变音符号的网址.
I want to open an URL in chrome with a batch file. This works for normal URLs, but it doesn't for URLs with umlauts.
start chrome.exe https://trends.google.de/trends/explore?q=mähroboter
我不能使用ae"代替ä",因为它会在 Google 趋势上给我不同的结果.
I cannot use "ae" as a replacement for "ä", as it will give me different results on Google Trends.
当我保持这样时,浏览器中的 URL 变为
When I keep it like this, the URL in my browser changes to
https://trends.google.de/trends/explore?q=mA4hroboter
这又给了我错误的结果.它必须是ä".
which again gives me the wrong results. It needs to be "ä".
我尝试使用文件编码.目前没有 BOM 的 UTF8.我尝试了带有 BOM、ANSI 的 UTF8,来回转换.似乎没有任何效果.我该怎么做才能让它发挥作用?
I tried playing around with the file encoding. Currently UTF8 without BOM. I tried UTF8 with BOM, ANSI, converting to and fro. Nothing seemed to work. What can I do to make it work?
推荐答案
URLs must be URL encoded with percent-encoded bytes.
这意味着 URL 中的德语变音 ä
必须首先 UTF-8 用两个字节和十六进制值编码 C3A4
和下一个百分比编码导致 URL 字符串中的 %C3%A4
:
That means the German umlaut ä
in a URL must be first UTF-8 encoded with the two bytes with the hexadecimal values C3 A4
and next percent-encoded resulting in %C3%A4
in the URL string:
https://trends.google.de/trends/explore?q=m%C3%A4hroboter
在批处理文件中,必须使用额外的百分号对百分号进行转义,以使其被 Windows 命令处理器解释为文字字符而不是
In a batch file a percent sign must be escaped with an additional percent sign to get it interpreted by Windows command processor as literal character and not
- 作为批处理文件参数引用的开始,如在命令提示符窗口中运行
call/?
时命令 CALL 输出的帮助所解释的,或 - 在命令提示符窗口中运行
for/?
时通过命令 FOR 输出的帮助解释的循环变量引用的开始,或 - 在命令提示符窗口中运行
set/?
时命令 SET 输出的帮助解释了环境变量引用的开始/结束.
- as beginning of a batch file argument reference as explained by help of command CALL output on running
call /?
in a command prompt window, or - beginning of a loop variable reference as explained by help of command FOR output on running
for /?
in a command prompt window, or - beginning / end of an environment variable reference as explained by help of command SET output on running
set /?
in a command prompt window.
所以在批处理文件中必须使用:
So in the batch file must be used:
start chrome.exe https://trends.google.de/trends/explore?q=m%%C3%%A4hroboter
这篇关于使用批处理打开包含元音变音的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!