diff options
| author | Vicent Marti <tanoku@gmail.com> | 2011-10-26 16:43:55 -0700 |
|---|---|---|
| committer | Carlos MartÃn Nieto <carlos@cmartin.tk> | 2011-10-26 17:43:44 -0700 |
| commit | 11d51ca63184b760e2537bbe08c5ca4c63bd4854 (patch) | |
| tree | 3ed2702d52187a47ce4a4ad80f2b2ae0c1010beb /src/win32/dir.c | |
| parent | c2fbe423465e1fa02a7e681f6b4aaee877e3de03 (diff) | |
| download | libgit2-11d51ca63184b760e2537bbe08c5ca4c63bd4854.tar.gz | |
windows: Add support for non-UTF codepages
Our previous assumption that all paths in Windows are encoded in UTF-8
is rather weak, specially when considering that Git is
encoding-agnostic.
These set of functions allow the user to change the library's active
codepage globally, so it is possible to access paths and files on all
international versions of Windows.
Note that the default encoding here is UTF-8 because we assume that 99%
of all Git repositories will be in UTF-8.
Also, if you use non-ascii characters in paths, anywhere, please burn on
a fire.
Diffstat (limited to 'src/win32/dir.c')
| -rw-r--r-- | src/win32/dir.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/win32/dir.c b/src/win32/dir.c index ab50318e3..fea74b4eb 100644 --- a/src/win32/dir.c +++ b/src/win32/dir.c @@ -6,7 +6,8 @@ */ #define GIT__WIN32_NO_WRAP_DIR #include "dir.h" -#include "utf8-conv.h" +#include "utf-conv.h" +#include "git2/windows.h" static int init_filter(char *filter, size_t n, const char *dir) { @@ -43,7 +44,7 @@ git__DIR *git__opendir(const char *dir) } strcpy(new->dir, dir); - filter_w = conv_utf8_to_utf16(filter); + filter_w = gitwin_to_utf16(filter); new->h = FindFirstFileW(filter_w, &new->f); free(filter_w); @@ -73,7 +74,7 @@ struct git__dirent *git__readdir(git__DIR *d) return NULL; d->entry.d_ino = 0; - WideCharToMultiByte(CP_UTF8, 0, d->f.cFileName, -1, d->entry.d_name, GIT_PATH_MAX, NULL, NULL); + WideCharToMultiByte(gitwin_get_codepage(), 0, d->f.cFileName, -1, d->entry.d_name, GIT_PATH_MAX, NULL, NULL); return &d->entry; } @@ -90,7 +91,7 @@ void git__rewinddir(git__DIR *d) d->first = 0; if (init_filter(filter, sizeof(filter), d->dir)) { - filter_w = conv_utf8_to_utf16(filter); + filter_w = gitwin_to_utf16(filter); d->h = FindFirstFileW(filter_w, &d->f); free(filter_w); |
