0

I need to write a command line in the command prompt that references a file containing åäö in its name, but I can't seem to get it right. Windows should be set to codepage win1252 and the command prompt to oem850.

The specific filename is:

Förändringar.txt

I was able to use dir /x to get the short 8.3 filename and use that, but it bugs me to be unable to get the long name right...

Update:

The comments have led me to conclude that it's not a problem with the command prompt (cmd.exe to clarify). It seems to be a problem with the particular console application I was trying to run (gfix.exe from the Firebird database manager). Apparently it fails to correctly convert command line arguments from the console codepage to whatever it needs to use internally.

Kjell Rilbe
  • 459
  • 5
  • 11
  • What version of Windows are you on, and which command line interface (command.com (hopefully not), cmd.exe, powershell, anything third-party?) are you using? I have never had anything like the problem you are describing, which leads me to believe that you are doing something unusual. Please **[edit]** your question to clarify. – user Feb 10 '15 at 08:18
  • äöüÄÖÜ work fine here with cmd.exe, dir and ren, so what exactly does not work as expected? – Werner Henze Feb 10 '15 at 10:07
  • Aha, sorry. I think it's not a command prompt (cmd.exe) problem, but a problem with the actual console application I was trying to invoke. It seems it fails to convert the filename from the command line args correctly from the console codepage. I guess I'll have to check with the app developers. (It's the Firebird database manager's gfix utility.) – Kjell Rilbe Feb 10 '15 at 12:26
  • Please [edit] your question and show a code snippet satisfying [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) rules and specify whether you do run `gfix.exe` from pure `cmd` or from a batch script. Use `chcp 1257` or `chcp 1254` prior to running `gfix.exe` from an open `cmd` window. Simply: use `chcp` to a code page where all `åäö` characters are defined. – JosefZ Jul 01 '16 at 19:51

1 Answers1

-1

The normal command prompt in Windows is CMD.EXE. This is a Unicode program. In Unicode, there's no need for things like "Win1252" and "OEM850".

I suspect that you're using batch files, as those can be non-Unicode. CMD.EXE will understand batch files that are in non-Unicode, but avoid them when using non-ASCII characters. Just use Unicode batch files.

MSalters
  • 8,185
  • 1
  • 23
  • 29
  • Unfortunately, if not cmd.exe then at least the Windows console itself still uses codepages to this day, and while programs _can_ output Unicode, they must go out of their way to do so. (I have dealt with this for a decade and just re-tested on a fresh Server 2012 R2 system to make sure.) The CMD built-in `dir` command only shows question marks for characters outside the current OEM codepage (as shown by `chcp`), and the console itself doesn't let me input them (e.g. pressing `ąčęė` causes `acee` to appear if the codepage is not 775). PowerShell doesn't get this right either. – u1686_grawity Feb 10 '15 at 09:04
  • 1
    @grawity: I don't think it does. The question marks are not a result of code pages, that's the result of using a font which doesn't have the characters. Programs don't need to do something special for the console, `WriteConsole` maps to `WriteConsoleW` (wide) for Unicode programs. Just like `MessageBox`->`MessageBoxW`. – MSalters Feb 10 '15 at 09:10
  • Hmm, looks like you're right about the font. I can't believe I forgot that _again_. I keep rediscovering this every few months... – u1686_grawity Feb 10 '15 at 09:26