-
November 12th, 2013, 11:10 AM
#1
Rename failed with file name had space, hyphen etc after unicode support.
Hi,
I intent to use this mechanism for rename the file because the file name consists Unicode characters
I would like to know why the return value of "MoveFileExW" is false for file name consists 'space','hyphen' etc.(sometimes even without a Unicode character).for accepting 'space','hyphen' what type of conversion I would use [I.e.: Does the root cause of failure is due to CP_UTF8 type use]
Please see the code
Code:
//! inputPath & final_inputPath consist source and destination file name and are std::string
//! Both are in same directory F:\test_files\
std::wstring unicode_input_original;
int unicode_input_length_original = 0
std::wstring unicode_input_final;
int unicode_input_length_final = 0;
unicode_input_length_original = MultiByteToWideChar(CP_UTF8,0,inputPath.data(),inputPath.length(),NULL,0);
unicode_input_original.resize(unicode_input_length_original);
MultiByteToWideChar(CP_UTF8,0,inputPath.data(),inputPath.length(),&unicode_input_original[0],unicode_input_original.length());
const wchar_t *input_name_original = unicode_input_original.c_str();
unicode_input_length_final = MultiByteToWideChar(CP_UTF8,0,final_inputPath.data(),final_inputPath.length(),NULL,0);
unicode_input_final.resize(unicode_input_length_final);
MultiByteToWideChar(CP_UTF8,0,final_inputPath.data(),final_inputPath.length(),&unicode_input_final[0],unicode_input_final.length());
const wchar_t *input_name_final = unicode_input_final.c_str();
bool ret = MoveFileExW(input_name_original,input_name_final,MOVEFILE_REPLACE_EXISTING);
-Dave.
-
November 12th, 2013, 11:37 AM
#2
Re: Rename failed with file name had space, hyphen etc after unicode support.
I would like to know why the return value of "MoveFileExW" is false
Where is your call to GetLastError? That is what you should call immediately after calling MoveFileExW if it returns 0.
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
Regards,
Paul McKenzie
-
November 12th, 2013, 12:53 PM
#3
Re: Rename failed with file name had space, hyphen etc after unicode support.
Where does inputPath & final_inputPath come from and how do you know they are UTF8 encoded?
Here's are some utility functions for doing the conversions: http://forums.codeguru.com/showthrea...31#post1790131
You may want to change the return type to bool so that it's easy to detect conversion errors.
gg
-
November 20th, 2013, 01:44 PM
#4
Re: Rename failed with file name had space, hyphen etc after unicode support.
Hi
h r u
i need your help pls if you have time
-
November 20th, 2013, 01:48 PM
#5
Re: Rename failed with file name had space, hyphen etc after unicode support.
Originally Posted by sarmad
Hi
h r u
i need your help pls if you have time
You need a new keyboard. The one you have seems to be dropping letters.
Once you get a keyboard that can type complete words, you may want to state what you'd like help with.
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
|