We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
我因为一些原因,必须在中文Windows下运行http服务,使用libhv时发现所有文件相关的方法是直接使用的标准库的方法,比如hv_exists、hlog的open这些,这些方法在中文windows下,由于系统的locale设置默认是中文936,系统会认为路径是gbk编码而不是utf8,导致无法读取中文路径,所有文件相关操作应该使用宽字符版本才可以正确操作。以hlog.c的打开日志文件句柄为例: #if (defined(OS_WIN) || defined(WIN32)) //修正中文windows路径操作 wchar_t wstr[MAX_PATH]; MultiByteToWideChar(CP_UTF8, 0, logger->cur_logfile, -1, wstr, sizeof(wstr) / sizeof(wstr[0])); logger->fp = wfopen(wstr, L"a"); #else logger->fp = fopen(logger->cur_logfile, "a"); #endif 又比如hbase中的hv_exists:
bool hv_exists(const char* path) { if (!path || path[0] == '\0') return false; #if (defined(WIN32) || defined(_WIN32) || defined(OS_WIN)) wchar_t wstr[MAX_PATH] = {0}; MultiByteToWideChar(CP_UTF8, 0, path, -1, wstr, sizeof(wstr) / sizeof(wstr[0])); DWORD dwAttrib = GetFileAttributesW(wstr); return (dwAttrib != INVALID_FILE_ATTRIBUTES); #else struct stat buffer; return (stat(path, &buffer) == 0); #endif }
The text was updated successfully, but these errors were encountered:
没有考虑windows下中文路径问题,如果你适配好了,欢迎提PR
Sorry, something went wrong.
已经提了PR,坐等大神接受。反正老外也不会关注中文问题,索性全部用中文了哈
No branches or pull requests
我因为一些原因,必须在中文Windows下运行http服务,使用libhv时发现所有文件相关的方法是直接使用的标准库的方法,比如hv_exists、hlog的open这些,这些方法在中文windows下,由于系统的locale设置默认是中文936,系统会认为路径是gbk编码而不是utf8,导致无法读取中文路径,所有文件相关操作应该使用宽字符版本才可以正确操作。以hlog.c的打开日志文件句柄为例:
#if (defined(OS_WIN) || defined(WIN32))
//修正中文windows路径操作
wchar_t wstr[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, logger->cur_logfile, -1, wstr, sizeof(wstr) / sizeof(wstr[0]));
logger->fp = wfopen(wstr, L"a");
#else
logger->fp = fopen(logger->cur_logfile, "a");
#endif
又比如hbase中的hv_exists:
The text was updated successfully, but these errors were encountered: