Problem with "é" in directory name

Home Forums Scripting DOS Command Shell Problem with "é" in directory name

This topic contains 2 replies, has 3 voices, and was last updated by  Kasi77 1 year, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • dreivilo47
    dreivilo47
    Participant
    #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?


    universal
    Member
    #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.

    Possible solutions:

    1. 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.
    2. Use a command-line editor. I believe the Nano editor is available for Windows.
    3. Switch to PowerShell, which uses Windows encoding.
    4. 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.
    5. Very impractical workaround: Don’t use accented characters in paths or filenames.

    Kasi77
    Member
    #391876

    Thank you for the fast reply and for the possible solutions [USER=”91538″]Ser Olmy[/USER]!
    I prefer solution 4, the ugly workaround. It’s easy, fast and effective.
    Thanks again, my problem is solved!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.