开发者

Equivalent of MSVC++ _wrename in linux g++?

开发者 https://www.devze.com 2023-03-14 13:11 出处:网络
Does anyone know if an equivalent of MSVC _wrename exist in linux g++ ? (equivalent of cstdio file rename fun开发者_如何学运维ction using const wchar_t* instead of const char* as parameter type for un

Does anyone know if an equivalent of MSVC _wrename exist in linux g++ ? (equivalent of cstdio file rename fun开发者_如何学运维ction using const wchar_t* instead of const char* as parameter type for unicode use)

Thanks !


The point is that most filesystems other than NTFS store their filenames in byte-strings. There is usually no explicit notion of encoding, but the filenames have to be strings of non-zero bytes terminated by a zero. So on all such systems, filesystem functions just take char* arguments for filenames, and you have to figure our yourself how to handle encoding issues (should there be any).

Windows is special because filenames in NTFS are null-terminated strings of 16-bit units. This goes hand-in-hand with the 16-bit wchar_t type on Windows and various _w* filesystem functions.


That's platform specific. I'm afraid you'll have to convert your const wchar_t* to const char* somehow. On Linux, i think you can use the iconv function.

EDIT: Boost probably has something for this

0

精彩评论

暂无评论...
验证码 换一张
取 消