Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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)
	HANDLE h = FindFirstFile(directory, dir);
	FindNextFile(h, dir);

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

Heres the only other significant code snippet for image loading:
		//appends the directory path to it to find the folder it's in.
		WCHAR directory[MAX_PATH];
		for(int i = 0; i < 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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!