Reading accented file names in VB6

I have a VB6 application that makes a list of folder directories and matches file names. Some of them are accented, for example, "Guimarães.txt" (small A with a tilde). Both the VB Dir function and the FileSystemObject functions cannot recognize the accented character and instead return the file name as "Guimar? Es.pdf", so I cannot open the file afterwards. I see the file correctly in Windows Explorer

This occurs in only one environment running Windows Server 2003 R2. On our test systems, we can read the file correctly, although it is mainly Windows 2008 and Windows 7. At first I thought it was not a FSO version, but since "Dir" gives the same results, I don’t think so. In addition, when I write the file name to the log file, this is also not true. Therefore, I think that at a very early stage he cannot cope with character and replaces it with a question mark.

What I need to install is the cause of the problem: it is up to the Windows version or my regional settings (which I can’t see because my account is locked), and what can I do to solve the problem. At the moment, I have asked users not to use these characters, but this is not a long-term solution.

Thanks.

+6
source share
1 answer

Well, the name of the file read from disk uses unicode. When you try to display this, the font used does not support this character, so it displays a “?”, But writing to the disk writes the correct representation. When it is then passed into a file function, it is "converted" to MBCS or another encoding, which is then delayed.

You can either change your code to use the native Win32 API calls, or simply change the "langauge for non-Unicode programs" to the language used in the file name.

+2
source

Source: https://habr.com/ru/post/892217/


All Articles