dreivilo47ParticipantOctober 23, 2017 at 11:43 am #167265
I have a problem with this line:
@start “” “C:privétest.txt”
When I try the line from the command line, there is no error.
When I try the line from a batch file, there is an error. The error is: Cannot find the file C:privétest.txt
The “é” character is displayed “strange” in the error message, not as an “é”.
Is there a solution without changing the directory name “privé” in another name?
universalMemberOctober 23, 2017 at 4:43 pm #388837
You’ve just run into Windows’ inconsistent handling of non-ASCII character sets.
An accented character typed in a regular command window is not the same as the exact same character typed into a Windows application like, say, Notepad. In other words, if you edit batch files using a Windows application that assumes encoding type Windows 1252 or somesuch, accented characters will appear mangled when viewed from the command line.
- Create/edit your batch files with a Windows application that allows you to specify the encoding of non-ASCII characters in text files. In the US, codepage 437 is usually the one you want, while Western Europe uses codepage 850. For instance, LibreOffice Writer will let you do this if you choose File > Open and select “Text – Choose Encoding” from the file type pulldown menu.
- Use a command-line editor. I believe the Nano editor is available for Windows.
- Switch to PowerShell, which uses Windows encoding.
- Ugly workaround: Use redirection and the echo command to place the required character(s) at the end of your file (echo é >> yourfile.cmd), and then use cut and paste to put the character(s) in the right place(s). The character will look wrong in a Windows application like Notepad, but will function correctly when used in a cmd shell environment.
- Very impractical workaround: Don’t use accented characters in paths or filenames.
You must be logged in to reply to this topic.