fopen 与 unicode 文件名 [英] fopen with unicode filename

查看:80
本文介绍了fopen 与 unicode 文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用一个接受文件名作为字符串的库(const char*).内部文件使用 fopen 打开.有没有办法让这个库接受unicode文件名?我可以使用 WideCharToMultiByte 在将它们传递给库之前将 unicode 名称转换为 utf?

I have to use a library that accepts file names as strings (const char*). Internally files are opened with fopen. Is there a way to make this library to accept unicode file name? Can I use WideCharToMultiByte to convert unicode names into utf before passing them to the library?

一种可能(不受欢迎)的解决方案是更改库接口(char* -> wchar_t*)并将 fopen 替换为 Windows 特定的 _wopen>.另一种解决方案是使用创建文件符号链接并将它们传递给库,但仅限于 NTFS 卷.

One possible (undesirable) solution is to change library interface (char* -> wchar_t*) and replace fopen with windows specific _wopen. Another solution is to use create symbolic links to files and pass those to the library, but it is limited to NTFS volumes only.

推荐答案

最好的方法是重写 lib... Just my 2 Cents.

Best way would be to rewrite the lib... Just my 2 Cents.

但如果要打开现有文件,您可以使用 GetShortPathName您可以在此处找到有关这种方式的现有讨论.

But if it is just about to open an existing file you can use GetShortPathName You find an existing discussion about this way here.

这篇关于fopen 与 unicode 文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆