Sign in to follow this  
chillypacman

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

Recommended Posts

chillypacman    100
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->cFileName, false);
		std::string t = _tochar(ls, false);
                          loadImage(ls);
	}
}

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[i] = *(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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this