Windows Codepage Interactions with Standard C/C++ filenames? -


A customer is complaining that our code was used to write files with Japanese characters in filename but now all Does not work in cases. We have always used the old four * strings to represent the filenames, so it came from a shock to me that it never works, and we have not done anything that I know is to stop working. Should have had I sent them a file with an embedded file name exported from our software, and it seems that strings use hex characters 82 and 83 because the first letter of double-byte sequence to represent Japanese characters Is used. Calling around online makes me believe that this is probably SHIFT_JIS and / or Windows codepage 932.

It seems to me that what is already happening is both FOPPIN and OFFRREME :: use this codepage to open the acceptable filename; Now only pops up, I have examined the visual studio FOPN docs, and I am not getting any indication that what makes the acceptable string to pass the FOPIN.

In short run, I'm hoping that someone can put some light on a specific Windows FOPN vs. offstream :: Open Issues In the long run for me, I'm actually on Windows, Linux, and OS X Would like to know the acceptable way of opening Unicode (and other?) Filenames in C ++ Edit to edit: I believe that the work is done in the "C" locale, while those who do not work do whatever they do in the default locale of the customer goes. However, this has been the case for years, and the old version of the program still works on our system today, so we take a long time to explain this problem.

Update: A small test program for the client I sent has verified that the Fopen works fine with the SHIFT_JIS filename, and std :: ofstream does not work. This is in Visual Studio 2005, and despite this I have used default locale or "C" locale.

I am still interested if someone has an explanation for this behavior (and why it changed mysteriously - maybe VS 2005's service pack?) And the Unicode filenames in portable C ++ code Is hoping to make a comprehensive "best practices" to handle.

Forums such as the phpon or offstream :: functions are named as four * names, but its The meaning is done in the system code page.

This means that it may be shown as a Japanese character shift-jis (cp932) or Chinese Simplified (Big 5 / CP 936), Korean, Arabic, Russian, Name (unless it matches the OS system code page).

It also means that it can only use Japanese file names on Japanese systems. Change the system code page and the application "stops working" I suspect that this is the same (there has not been any major change in this area in Windows 2000).

In this way you can consider system code page:

In the long run you can consider going to Unicode (and using _wfopen, wofstream).


Comments