Unicode filenames with DOS Batch commands

There is some weirdness happening when trying to pass filenames containing unicode characters ć and č.

Here is a minimum example:

  1. Create a filename ćčžšđ.txt
  2. Select it
  3. Run a button with this MS-DOS Batch Function command:
echo {file$}
pause

The unexpected output is: ccžšd.txt (note the first two characters are incorrect).
This gets passed incorrectly to all external programs (such as ffmpeg), so it's not an issue specific to the echo command.

DOS Command Prompts can’t display Unicode correctly, something Microsoft have never fixed. It’s unrelated to Opus and happens if you do the same thing from a Command Prompt opened normally.

If I use the dir command in the Command Prompt the filename gets displayed correctly there.

But the Opus' {file$} (and other similar codes for passing filenames) gets passed to the ffmpeg incorrectly, the Command Prompt is irrelevant here, I just used its echo command to easily visualize the problem.

Passing the file to the ffmpeg manually works, it fails only when passed via Opus...

Can you use a button with Standard Function? I am pretty sure the filename will get passed correctly.

1 Like

Add @codepage:65001 as the first line of the function.

3 Likes

Some interesting discussion around making cmd.exe use UTF8 (codepage 65001) here, FWIW: Using UTF-8 Encoding (CHCP 65001) in Command Prompt / Windows Powershell (Windows 10) - Stack Overflow

2 Likes

I just can't get it to work with ffmpeg.exe -i {filepath$} -f mp4 -vcodec libx264 -crf 28 test.mp4 in the Standard Opus function mode...
The cmd window of the ffmpeg flashes in the taskbar and immediately disappears, so I don't know what the error is (I tried other non-unicode filenames too).

Thanks, this is actually what helped! I've already tried it before making this post, but I didn't put the @ before so that's why I thought it didn't work and what prompted me to ask here.