管理与重音字符路径 [英] Manage paths with accented characters

查看:121
本文介绍了管理与重音字符路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个批次,指定名称中包含重音字符的路径,文件不被发现到文件系统,而
剥离出路径中的所有重音字符,这些文件被发现。尽管如此,
我必须管理与重音字符写的路径。有什么办法来解决这个问题?

In a batch, specifying a path whose name contains an accented character, files are not being found into the file System while stripping out all accented character in the path, these files are found. Nevertheless, I have to manage paths written with accented character. Is there any way to solve this issue?

如果您需要了解我的操作系统,我在SEVEN 32。

If you need to know my OS, I'm on SEVEN 32.

感谢

推荐答案

批量使用默认配置不能打印单code字符,但是可以识别的字符并使用它。
这意味着你不能打印ú,但你可以查看在一个文件夹名为U或触摸被称为u。

Batch by default configuration can't print unicode characters but CAN recognize that chars and use it. That means you can't print "ú" but you can acces to a folder called "ú" or touch a file called "ú".

这时如果你的脚本不能存取权限重音字符的文件可能的原因是因为你的脚本编码不是ANSI,
所以在记事本中打开脚本,并确保将其与ANSI编码保存(无UTF-8或单code)。

Then if your script fails to acces a file with accented characters maybe the reason is because the encoding of your script is not ANSI, so open the script in notepad and ensure to save it with ANSI encoding (no utf-8 or unicode).

示例:

@echo off

CHCP 850 >NUL

for %%# in (*.txt) do (

    Echo [+] reading File: .\%%~nx# | MORE
    Type "%%~nx#"
) 

Pause>NUL

输出:

[+] reading File: .\áéíóúàèìòù ñ Ñ ç Ç.txt

This is the text content of my file with ISO-Latin characters

如果您想打印在CMD重音符号,那么你需要做的焦炭转化,这可以做的伎俩:

If you want to print accented characters in CMD then you need to make the char conversion, this can do the trick:

@echo off
CHCP 850 >NUL
copy con Mychars.txt

在提示您会写你想要的字符,例如éíóú,那么你会得到这个内容的Mychars.txt文本文件:

In that prompt you will write the characters you want, for example "éíóú", then you will get a "Mychars.txt" textfile with this content:

 ‚¡¢£

现在您可以使用字符打印的字符重音:

Now you can use that chars to print the accented chars:

@echo off
echo ‚¡¢£
Pause>NUL

输出:

éíóú

PS1:记住要尽我说节省ANSI编码脚本​​的事情

PS1: Remember to do all the things that I said saving the script in ANSI encoding.

PS2:请注意,我如何使用CHCP 850命令,这意味着CMD的codePAGE,默认情况下CMD使用850 codePAGE但我启动CMD使用默认的1250 codePAGE到避免所有这些问题,所以在我的例子我需要使用$ C $ 850 CPAGE展现你。

PS2: Notice how I'm using CHCP 850 command, that means the codepage of the CMD, By default CMD uses the 850 codepage but I launch the CMD with a default 1250 codepage to avoid all those problems so in my examples I needed to use codepage 850 to show you.

您可以使用注册表项设置默认CMD codePAGE:

You can set the default CMD Codepage with a registry key:

REG ADD "HKCU\Software\Microsoft\Command Processor" /V "Autorun" /T "REG_SZ" /D "chcp 1250 >NUL" /F >NUL 2>&1

你可以读到这里的codepages:的http:// msdn.microsoft.com/en-us/library/cc195064.aspx

这篇关于管理与重音字符路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆