简体   繁体   English

外文字符替换为“?”

[英]Foreign language characters replaced by “?”

I am working on a program which takes file/folder names as input. 我正在研究一个将文件/文件夹名称作为输入的程序。 Currently when I try to run a file which has got foreign language character in its name it is replaced by a ? 当前,当我尝试运行名称中带有外文字符的文件时,将其替换为? For each of its character. 对于每个角色。 I am running my exe on command prompt so trying to run the particular file results in an error. 我在命令提示符下运行exe,因此尝试运行特定文件会导致错误。 When I am using DIR on command prompt it displays ? 当我在命令提示符下使用DIR时,它显示吗? For each character of the file name. 为文件名的每个字符。 Is there any way to display the actual foreign language characters in command prompt as I believe that could be causing my exe not to work any of those files. 有什么方法可以在命令提示符下显示实际的外语字符,因为我认为这可能会导致我的exe文件无法正常工作。 This is the text that I am trying to read - 科普書籍推展教案 which is being replaced by ? 这是我要阅读的文字-被取代的科普书籍推展教案? on the console. 在控制台上。

The command prompt can only display characters in your current ACP. 命令提示符只能显示当前ACP中的字符。 So, if you have files with names outside the ACP, you're going to see ?. 因此,如果您的文件名在ACP之外,则会看到?。 You can use changecp to pick a different CP, but here is no code page for full Unicode in the DOS box. 您可以使用changecp来选择其他CP,但是在DOS框中,这里没有完整Unicode的代码页。

Inside your code, you need to learn to use 'W' API to work with full unicode pathnames. 在代码内部,您需要学习使用“ W” API来处理完整的unicode路径名。 The safest thing is to just #define _UNICODE and use it uniformly. 最安全的方法是仅#define _UNICODE并统一使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM