Unicode Support for Windows Renaming API.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Unicode Support for Windows Renaming API.

  1. #1
    Join Date
    Apr 2008
    Posts
    156

    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.

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,639

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    156

    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

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,523

    Re: Unicode Support for Windows Renaming API.

    Quote Originally Posted by Dave1024 View Post
    ...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:
    FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, 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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center