Skip to content

Support win32 chinese model path #349

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion chatglm.cpp
Original file line number Diff line number Diff line change
@@ -299,6 +299,15 @@ std::string PerfStreamer::to_string() const {
return oss.str();
}

#ifdef _WIN32
static std::wstring convert_to_wstring(const std::string &str) {
int count = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, nullptr, 0);
std::wstring wstr(count, 0);
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &wstr[0], count);
return wstr;
}
#endif

#ifdef _POSIX_MAPPED_FILES
MappedFile::MappedFile(const std::string &path) {
int fd = open(path.c_str(), O_RDONLY);
@@ -318,7 +327,8 @@ MappedFile::~MappedFile() { CHATGLM_CHECK(munmap(data, size) == 0) << strerror(e
#elif defined(_WIN32)
MappedFile::MappedFile(const std::string &path) {

int fd = open(path.c_str(), O_RDONLY);
const std::wstring wpath = convert_to_wstring(path);
int fd = _wopen(wpath.c_str(), O_RDONLY);
CHATGLM_CHECK(fd > 0) << "cannot open file " << path << ": " << strerror(errno);

struct _stat64 sb;