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

拟墨画扇 提交于 2019-12-25 01:38:21

问题


Does anyone know if an equivalent of MSVC _wrename exist in linux g++ ? (equivalent of cstdio file rename function using const wchar_t* instead of const char* as parameter type for unicode use)

Thanks !


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/6442045/equivalent-of-msvc-wrename-in-linux-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!