-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Adds support for UTF-8/wchar throughout the application
Showing
12 changed files
with
127 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "lib/cxxopts"] | ||
path = lib/cxxopts | ||
url = [email protected]:jarro2783/cxxopts.git | ||
[submodule "lib/cli11"] | ||
path = lib/cli11 | ||
url = [email protected]:CLIUtils/CLI11.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
#include <fstream> | ||
#include <filesystem> | ||
|
||
namespace fs = std::filesystem; | ||
|
||
std::wstring escapedPathString(const fs::path& path); | ||
std::string ansiPathString(const fs::path& path); | ||
std::string utf8String(const std::wstring& wstr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule cxxopts
deleted from
78b90d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <encoding.hh> | ||
#include <Windows.h> | ||
#include <sstream> | ||
|
||
std::wstring escapedPathString(const fs::path& path) | ||
{ | ||
std::wstringstream wss; | ||
wss << path; | ||
return wss.str(); | ||
} | ||
|
||
// Taken and modified from https://gist.github.com/pavel-a/090cbe4b2aea9a054c55974b7c7be634 (Pavel A.) | ||
std::string ansiPathString(const fs::path& path) | ||
{ | ||
std::wstring widePath{ path.wstring() }; | ||
|
||
std::string resultPath; | ||
resultPath.reserve(widePath.size()); | ||
|
||
for (const WCHAR& w : widePath) | ||
{ | ||
if (w == 0 || w > 0xFF) | ||
break; | ||
|
||
resultPath += static_cast<char>(w & 0xFF); | ||
} | ||
|
||
if (resultPath.size() == widePath.size()) | ||
return resultPath; | ||
|
||
WCHAR shortPath[MAX_PATH]{ }; | ||
DWORD r{ GetShortPathNameW(widePath.c_str(), shortPath, MAX_PATH) }; | ||
|
||
if (r == 0 || r >= MAX_PATH) | ||
return { }; | ||
|
||
std::wstring shortPathWstr{ shortPath }; | ||
resultPath.clear(); | ||
|
||
for (const WCHAR& w : shortPathWstr) | ||
{ | ||
if (w == 0) | ||
break; | ||
|
||
if (w > 0xFF) | ||
return { }; | ||
|
||
resultPath += static_cast<char>(w & 0xFF); | ||
} | ||
|
||
return resultPath; | ||
} | ||
|
||
std::string utf8String(const std::wstring& wstr) | ||
{ | ||
int size{ WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, nullptr, 0, nullptr, nullptr) }; | ||
std::string buffer(size - 1, '\0'); | ||
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, buffer.data(), size - 1, nullptr, nullptr); | ||
return buffer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters