Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode file/dir name bug fix #292

Open
wellshsu opened this issue Jun 6, 2023 · 0 comments
Open

Unicode file/dir name bug fix #292

wellshsu opened this issue Jun 6, 2023 · 0 comments

Comments

@wellshsu
Copy link

wellshsu commented Jun 6, 2023

  • add 'utf8_to_gb' func into commands.cpp
static std::string utf8_to_gb(const char* str)
{
	std::string result;
	WCHAR* strSrc;
	LPSTR szRes;

	int i = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
	strSrc = new WCHAR[i + 1];
	MultiByteToWideChar(CP_UTF8, 0, str, -1, strSrc, i);

	i = WideCharToMultiByte(CP_ACP, 0, strSrc, -1, NULL, 0, NULL, NULL);
	szRes = new CHAR[i + 1];
	WideCharToMultiByte(CP_ACP, 0, strSrc, -1, szRes, i, NULL, NULL);

	result = szRes;
	delete[]strSrc;
	delete[]szRes;

	return result;
}
  • modify 'get_encrypted_files' func in commands.cpp
	while (ls_files_stdout->peek() != -1) {
		std::string		mode;
		std::string		object_id;
		std::string		stage;
		std::string		filename;
		*ls_files_stdout >> mode >> object_id >> stage >> std::ws;
		std::getline(*ls_files_stdout, filename, '\0');
		filename = utf8_to_gb(filename.c_str()).c_str();
  • modify 'status' func in commands.cpp
	while (output.peek() != -1) {
		std::string		tag;
		std::string		object_id;
		std::string		filename;
		output >> tag;
		if (tag != "?") {
			std::string	mode;
			std::string	stage;
			output >> mode >> object_id >> stage;
			if (!is_git_file_mode(mode)) {
				continue;
			}
		}
		output >> std::ws;
		std::getline(output, filename, '\0');
		filename = utf8_to_gb(filename.c_str()).c_str();
  • rebuild binary and done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant