Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
62dc8e41
Commit
62dc8e41
authored
Dec 05, 2013
by
Denis Krjuchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Charset.cxx: replace \ with / when converting path to UTF-8 on Windows
parent
dc554ca6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
Charset.cxx
src/fs/Charset.cxx
+24
-3
No files found.
src/fs/Charset.cxx
View file @
62dc8e41
...
...
@@ -23,9 +23,12 @@
#include "Limits.hxx"
#include "system/FatalError.hxx"
#include "Log.hxx"
#include "Traits.hxx"
#include <glib.h>
#include <algorithm>
#include <assert.h>
#include <string.h>
...
...
@@ -74,13 +77,29 @@ GetFSCharset()
return
fs_charset
.
empty
()
?
"utf-8"
:
fs_charset
.
c_str
();
}
static
inline
void
FixSeparators
(
std
::
string
&
s
)
{
#ifdef WIN32
// For whatever reason GCC can't convert constexpr to value reference.
// This leads to link errors when passing separators directly.
auto
from
=
PathTraitsFS
::
SEPARATOR
;
auto
to
=
PathTraitsUTF8
::
SEPARATOR
;
std
::
replace
(
s
.
begin
(),
s
.
end
(),
from
,
to
);
#else
(
void
)
s
;
#endif
}
std
::
string
PathToUTF8
(
const
char
*
path_fs
)
{
assert
(
path_fs
!=
nullptr
);
if
(
fs_charset
.
empty
())
return
std
::
string
(
path_fs
);
if
(
fs_charset
.
empty
())
{
auto
result
=
std
::
string
(
path_fs
);
FixSeparators
(
result
);
return
result
;
}
GIConv
conv
=
g_iconv_open
(
"utf-8"
,
fs_charset
.
c_str
());
if
(
conv
==
reinterpret_cast
<
GIConv
>
(
-
1
))
...
...
@@ -101,7 +120,9 @@ PathToUTF8(const char *path_fs)
if
(
ret
==
static_cast
<
size_t
>
(
-
1
)
||
in_left
>
0
)
return
std
::
string
();
return
std
::
string
(
path_utf8
,
sizeof
(
path_utf8
)
-
out_left
);
auto
result_path
=
std
::
string
(
path_utf8
,
sizeof
(
path_utf8
)
-
out_left
);
FixSeparators
(
result_path
);
return
result_path
;
}
char
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment