Public Group

Chinese/japanese characters - works on compile but doesn't when running from exe

This topic is 3897 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have this strange problem that I don't understand at all. Basically I read in the files (which are pictures) from a specific directory and load them into memory. I store the file names in an LPCWSTR vector (it's actually in a struct which is in a vector :p). Anyways, when I compile from visutal studio 2005 express it runs fine, it loads images with japanese/chinese filenames and displays the text in japanese/chinese (it also works for english words too). However, if I go to the debug folder and click on the exe from there the japanese/chinese named files don't load, only the english ones do. I don't understand it at all, shouldn't it work? I mean, isn't this the same exe I'm dealing with when I compile from inside visual studio? Or am I missing something here? Heres my code for retrieving the filenames and storing them:
void GamePlay::LoadPics(LPCWSTR directory)
{
LPWIN32_FIND_DATA dir = new WIN32_FIND_DATA;
HANDLE h = FindFirstFile(directory, dir);
FindNextFile(h, dir);

while(FindNextFile(h, dir) != 0)
{
LPCWSTR ls = _towchar(dir-&gt;cFileName, false);
std::string t = _tochar(ls, false);
}
}


		//appends the directory path to it to find the folder it's in.
WCHAR directory[MAX_PATH];
for(int i = 0; i &lt; name.length() + 3; i++)
directory = *(copy + i);

WCHAR dir2[] = L"../media/images/";
wcscat(dir2, directory);


Here I'm basically adding the directory since I already have the filename. dir2 produces garbage if I'm running it through the exe and trying to load japanese/chinese text otherwise it's fine. Like I said - the program works fine if I compile and run it but doesn't work with chinese/japanese filenames if I find the .exe in the debug directory and try to run that, instead it shows garbage, but it works fine with english filenames. I don't get it at all, shouldn't it behave the same way whether I compile and run it or click on run it from the exe it created in the debug folder? oh! also I'm not sure if it's relevent but I get a ton of compiler warnings (like C4995) and I also have /FORCE:MULTIPLE for commandline (otherwise I get compiler rrors) and finally I have set it to ignore the following libraries: MSVCRTD;/NODEFAULTLIB:"atlthunk". Again, I'm really not sure whats going on, why it runs after compiling but refuses to run from the exe. It's causing me some major headaches. and this has nothing to do with the directory being different, I've checked for that possibility and it simply isn't the case.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• Forum Statistics

• Total Topics
631788
• Total Posts
3002356
×