-
November 7th, 2013, 06:49 AM
#1
Unicode Support for Windows Renaming API.
Hello,
I had a file which has name like SIRÃO.wav
Since this file name has special unicode character all file API's are failed.
I would like to rename this file using Windows API. How can achieve this?
std::string filename variable hold this value as SIRÃO.wav.
I try to read the file using file API after perform a conversion.
Code:
const int utf16_length = MultiByteToWideChar(CP_UTF8,0,filename.data(),filename.length(),NULL,0);
std::wstring utf16;
utf16.resize(utf16_length);
MultiByteToWideChar(CP_UTF8,0,filename.data(),filename.length(),&utf16[0],utf16.length());
const wchar_t *name = utf16.c_str();
Please help me to rename the file with unicode character.
Dave.
-
November 7th, 2013, 07:43 AM
#2
Re: Unicode Support for Windows Renaming API.
To open/rename/delete such files, your application would need to use the Unicode versions of the Windows API functions.
Even if compiling your c++ app as a unicode build, some of the C++ classes will still assume file data is single-byte.
if you use something like fstream, then the filename will Always assume single-byte. you'll need to change to wfstream to get unicode filenames. So to get unicode API's, for some of the c++ libs you'll need to use alternate classes.
-
November 7th, 2013, 08:34 AM
#3
Re: Unicode Support for Windows Renaming API.
Hi,
what is the specific setting to use unicode API in MSVC project properties.?
Did i install any package for the same?
Dave
-
November 11th, 2013, 05:30 PM
#4
Re: Unicode Support for Windows Renaming API.
Originally Posted by Dave1024
...Please help me to rename the file with unicode character.
What API did you try?
Did you see MoveFile function
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|