1

I am using CFileFind to get files list . i have an issue with one particular file always. getting file title with extra character '?' appended .

original name : _KO - Ennamo Yedho Video Song HD_test‏.txt

retrieved name : _KO - Ennamo Yedho Video Song HD_test?.txt

   CFileFind finder ;

    bool bWorking = finder.FindFile ("F:\\*.*")  ;



     while (bWorking)
     {
        bWorking = finder.FindNextFile ( ) ;
        CString file_lst  =finder.GetFileTitle()  ;
     }

I also check the same in command prompt.Same problem is happening . Someone Guide me where i am wrong .

enter image description here

enter image description here

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
jack
  • 355
  • 1
  • 4
  • 12
  • 4
    The original file name contains some non-printing Unicode character. You need to work with wide (Unicode) strings, not ANSI strings, in your program. – Cody Gray - on strike Apr 12 '13 at 06:39
  • Thanks will look into it , Meanwhile clarify why i get the same issue in cmd prompt also ? has cmd prompt not handled wide strings? check the link for the cmd prompt image . – jack Apr 12 '13 at 07:01
  • No, by default the command prompt does not display Unicode. It uses the system ANSI/multi-byte character set. – Cody Gray - on strike Apr 12 '13 at 07:05
  • But i am using multi byte character set programming how to get unicode file name – jack Apr 12 '13 at 08:23
  • Stop using the multi-byte character set and use Unicode. It's pretty simple. There's no need for anything but Unicode anymore. – Cody Gray - on strike Apr 12 '13 at 20:34
  • I am using GetWindowTextW to get the correct file name. not change the project settings. Any way thanks for your helping @CodyGray . – jack Apr 15 '13 at 04:17
  • Okay, so you are using the correct function. The problem is that you're trying to display the string in the command prompt window, which doesn't support Unicode properly without [some cajoling](http://stackoverflow.com/questions/15826188/what-most-correct-way-to-set-the-encoding-in-c/15845530#15845530). For a quick test, try displaying the result of `GetWindowTextW` in a `MessageBoxW`. – Cody Gray - on strike Apr 15 '13 at 20:25

0 Answers0