Skip to content

Commit cc7258b

Browse files
author
MarcoFalke
committed
Merge #13877: utils: Make fs::path::string() always return utf-8 string on Windows
2c3eade Make fs::path::string() always return utf-8 string (Chun Kuan Lee) Pull request description: Imbue `fs::path` with `std::codecvt_utf8_utf16` at `SetupEnvironment()`, so that default string encoding will be utf-8 inside `fs::path`. Tree-SHA512: 0cb59464d777278decbf24771fc5ff0cb2caa7bc2fe8ee5cd36c97a2324873a3caad131f08f050393b488316ee7f4ab0b28b7fa4699e41839f8e51b9867d5118
2 parents 8efd874 + 2c3eade commit cc7258b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/fs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include <boost/filesystem.hpp>
1212
#include <boost/filesystem/fstream.hpp>
13-
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
1413

1514
/** Filesystem operations and types */
1615
namespace fs = boost::filesystem;

src/qt/guiutil.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
#include <QFontDatabase>
6161
#endif
6262

63-
static fs::detail::utf8_codecvt_facet utf8;
64-
6563
namespace GUIUtil {
6664

6765
QString dateTimeStr(const QDateTime &date)
@@ -764,12 +762,12 @@ void setClipboard(const QString& str)
764762

765763
fs::path qstringToBoostPath(const QString &path)
766764
{
767-
return fs::path(path.toStdString(), utf8);
765+
return fs::path(path.toStdString());
768766
}
769767

770768
QString boostPathToQString(const fs::path &path)
771769
{
772-
return QString::fromStdString(path.string(utf8));
770+
return QString::fromStdString(path.string());
773771
}
774772

775773
QString formatDurationStr(int secs)

src/util.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,11 @@ void SetupEnvironment()
12061206
// A dummy locale is used to extract the internal default locale, used by
12071207
// fs::path, which is then used to explicitly imbue the path.
12081208
std::locale loc = fs::path::imbue(std::locale::classic());
1209+
#ifndef WIN32
12091210
fs::path::imbue(loc);
1211+
#else
1212+
fs::path::imbue(std::locale(loc, new std::codecvt_utf8_utf16<wchar_t>()));
1213+
#endif
12101214
}
12111215

12121216
bool SetupNetworking()

test/lint/lint-includes.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ EXPECTED_BOOST_INCLUDES=(
5454
boost/chrono/chrono.hpp
5555
boost/date_time/posix_time/posix_time.hpp
5656
boost/filesystem.hpp
57-
boost/filesystem/detail/utf8_codecvt_facet.hpp
5857
boost/filesystem/fstream.hpp
5958
boost/multi_index/hashed_index.hpp
6059
boost/multi_index/ordered_index.hpp

0 commit comments

Comments
 (0)