é 换成了 e?在 windows Java

é replaced by e? on windows Java

所以我正在制作一个 Java app/program 来备份特定文件夹(文件夹名称很长,但它以 "Pokémon" 开头),我的问题是这个文件夹包含重音符号(这个 é)。我有一个 mac,当我 运行 程序时,它 运行 没问题,但每当我在 Windows 上尝试它时,我的程序都会搜索一个文件夹而不是“ é”,我看到一个 "e?"(在控制台中,当我打印路径字符串时,我得到这个 Poke?mon)。 Windows格式有问题吗?我该如何解决这个问题?

void SaveNow (String folderName) {
    String fullOriginalPath = getMCPath() + "saves/Pokémon Cobalt and Amethyst [DEMO]";
    String fullNewPath = getMCPath() + "PokeCA/" + folderName;
    System.out.println("Path to original PokeCA map: " + fullOriginalPath); //At this point, the é is replaced by e?
    System.out.println("Path to backup PokeCA map: " + fullNewPath);

    if (OsUtils.isWindows()) {
        fullOriginalPath = MakeWinPath(fullOriginalPath); //Replaces all / by \ because Windows
        fullNewPath = MakeWinPath(fullNewPath); //Same
    }

    File source = new File(fullOriginalPath);
    File dest = new File(fullNewPath);

    try {
        FileUtils.copyDirectory(source, dest);
        System.out.println("Successfully backuped map!");
        JOptionPane.showMessageDialog(frmSave, "Successfully backuped map!");
    } catch (IOException e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(frmSave, "Error, could not backup map... ;(");
    }

注意:此外,我希望它适用于所有 OS,这就是我使用 OsUtils.isWindows() 修改路径的原因。

谢谢!

我能够解决问题!感谢所有帮助过我的人!

首先,由于编码问题,我不得不将 "saves/Pokémon Cobalt and Amethyst [DEMO]" 替换为 "saves/Pok" + '\u00e9' + mon Cobalt and Amethyst [DEMO]"。

其次,在我更改所有“/"s to "\”的函数中,我使用 return input.replaceAll("/", "\"); 将其更改为 return input.replace("/", "\"); 修复了崩溃...