From ed1842a743f59c0c7ef6937720ad39bf434cb13f Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 3 May 2021 23:09:13 -0400 Subject: [PATCH] Rename string::U8toU16 to UTF8toUTF16 and U16toU8 to UTF16toUTF8. --- include/string.hpp | 4 ++-- src/asset.cpp | 4 ++-- src/common.cpp | 2 +- src/plugin.cpp | 2 +- src/string.cpp | 4 ++-- src/system.cpp | 20 ++++++++++---------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/string.hpp b/include/string.hpp index bf30f2ff..b6f0a264 100644 --- a/include/string.hpp +++ b/include/string.hpp @@ -60,8 +60,8 @@ These are only defined on Windows because the implementation uses Windows' API, std::string and char* variables are considered UTF-8, anywhere in the program. See https://utf8everywhere.org/ for more information about VCV Rack's philosophy on string encoding, especially section 10 for rules VCV follows for handling text on Windows. */ -std::string U16toU8(const std::wstring& w); -std::wstring U8toU16(const std::string& s); +std::string UTF16toUTF8(const std::wstring& w); +std::wstring UTF8toUTF16(const std::string& s); #endif diff --git a/src/asset.cpp b/src/asset.cpp index 3a839b53..2b8b81a3 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -67,7 +67,7 @@ static void initSystemDir() { assert(length > 0); // Get folder of executable PathRemoveFileSpecW(moduleBufW); - systemDir = string::U16toU8(moduleBufW); + systemDir = string::UTF16toUTF8(moduleBufW); #endif #if defined ARCH_LIN // Use the current working directory as the default path on Linux. @@ -90,7 +90,7 @@ static void initUserDir() { wchar_t documentsBufW[MAX_PATH] = L"."; HRESULT result = SHGetFolderPathW(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, documentsBufW); assert(result == S_OK); - userDir = system::join(string::U16toU8(documentsBufW), "Rack"); + userDir = system::join(string::UTF16toUTF8(documentsBufW), "Rack"); #endif #if defined ARCH_MAC // Get home directory diff --git a/src/common.cpp b/src/common.cpp index b05671ad..4b82b214 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -6,7 +6,7 @@ #include FILE* fopen_u8(const char* filename, const char* mode) { - return _wfopen(rack::string::U8toU16(filename).c_str(), rack::string::U8toU16(mode).c_str()); + return _wfopen(rack::string::UTF8toUTF16(filename).c_str(), rack::string::UTF8toUTF16(mode).c_str()); } #endif diff --git a/src/plugin.cpp b/src/plugin.cpp index bdde93b4..229ba8ad 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -44,7 +44,7 @@ namespace plugin { static void* loadLibrary(std::string libraryPath) { #if defined ARCH_WIN SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); - std::wstring libraryFilenameW = string::U8toU16(libraryPath); + std::wstring libraryFilenameW = string::UTF8toUTF16(libraryPath); HINSTANCE handle = LoadLibraryW(libraryFilenameW.c_str()); SetErrorMode(0); if (!handle) { diff --git a/src/string.cpp b/src/string.cpp index 09d9235c..d0293367 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -206,7 +206,7 @@ bool CaseInsensitiveCompare::operator()(const std::string& a, const std::string& #if defined ARCH_WIN -std::string U16toU8(const std::wstring& w) { +std::string UTF16toUTF8(const std::wstring& w) { if (w.empty()) return ""; // Compute length of output buffer @@ -221,7 +221,7 @@ std::string U16toU8(const std::wstring& w) { } -std::wstring U8toU16(const std::string& s) { +std::wstring UTF8toUTF16(const std::string& s) { if (s.empty()) return L""; // Compute length of output buffer diff --git a/src/system.cpp b/src/system.cpp index 1d299e91..a35ad32f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -306,7 +306,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath throw Exception("Archiver could not set filter option: %s", archive_error_string(a)); #if defined ARCH_WIN - r = archive_write_open_filename_w(a, string::U8toU16(archivePath).c_str()); + r = archive_write_open_filename_w(a, string::UTF8toUTF16(archivePath).c_str()); #else r = archive_write_open_filename(a, archivePath.c_str()); #endif @@ -318,7 +318,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath struct archive* disk = archive_read_disk_new(); DEFER({archive_read_free(disk);}); #if defined ARCH_WIN - r = archive_read_disk_open_w(disk, string::U8toU16(folderPath).c_str()); + r = archive_read_disk_open_w(disk, string::UTF8toUTF16(folderPath).c_str()); #else r = archive_read_disk_open(disk, folderPath.c_str()); #endif @@ -343,14 +343,14 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath // Convert absolute path to relative path std::string entryPath; #if defined ARCH_WIN - entryPath = string::U16toU8(archive_entry_pathname_w(entry)); + entryPath = string::UTF16toUTF8(archive_entry_pathname_w(entry)); #else entryPath = archive_entry_pathname(entry); #endif entryPath = getRelativePath(entryPath, folderPath); #if defined ARCH_WIN // FIXME This doesn't seem to set UTF-8 paths on Windows. - archive_entry_copy_pathname_w(entry, string::U8toU16(entryPath).c_str()); + archive_entry_copy_pathname_w(entry, string::UTF8toUTF16(entryPath).c_str()); #else archive_entry_set_pathname(entry, entryPath.c_str()); #endif @@ -362,7 +362,7 @@ void archiveFolder(const std::string& archivePath, const std::string& folderPath // Manually copy data #if defined ARCH_WIN - std::string entrySourcePath = string::U16toU8(archive_entry_sourcepath_w(entry)); + std::string entrySourcePath = string::UTF16toUTF8(archive_entry_sourcepath_w(entry)); #else std::string entrySourcePath = archive_entry_sourcepath(entry); #endif @@ -389,7 +389,7 @@ void unarchiveToFolder(const std::string& archivePath, const std::string& folder archive_read_support_format_tar(a); // archive_read_support_format_all(a); #if defined ARCH_WIN - r = archive_read_open_filename_w(a, string::U8toU16(archivePath).c_str(), 1 << 16); + r = archive_read_open_filename_w(a, string::UTF8toUTF16(archivePath).c_str(), 1 << 16); #else r = archive_read_open_filename(a, archivePath.c_str(), 1 << 14); #endif @@ -420,7 +420,7 @@ void unarchiveToFolder(const std::string& archivePath, const std::string& folder throw Exception("Unarchiver does not support absolute tar paths: %s", entryPath.c_str()); entryPath = (fs::u8path(folderPath) / fs::u8path(entryPath)).generic_u8string(); #if defined ARCH_WIN - archive_entry_copy_pathname_w(entry, string::U8toU16(entryPath).c_str()); + archive_entry_copy_pathname_w(entry, string::UTF8toUTF16(entryPath).c_str()); #else archive_entry_set_pathname(entry, entryPath.c_str()); #endif @@ -621,7 +621,7 @@ void openBrowser(const std::string& url) { std::system(command.c_str()); #endif #if defined ARCH_WIN - ShellExecuteW(NULL, L"open", string::U8toU16(url).c_str(), NULL, NULL, SW_SHOWDEFAULT); + ShellExecuteW(NULL, L"open", string::UTF8toUTF16(url).c_str(), NULL, NULL, SW_SHOWDEFAULT); #endif } @@ -636,7 +636,7 @@ void openFolder(const std::string& path) { std::system(command.c_str()); #endif #if defined ARCH_WIN - ShellExecuteW(NULL, L"explore", string::U8toU16(path).c_str(), NULL, NULL, SW_SHOWDEFAULT); + ShellExecuteW(NULL, L"explore", string::UTF8toUTF16(path).c_str(), NULL, NULL, SW_SHOWDEFAULT); #endif } @@ -648,7 +648,7 @@ void runProcessDetached(const std::string& path) { shExInfo.cbSize = sizeof(shExInfo); shExInfo.lpVerb = L"runas"; - std::wstring pathW = string::U8toU16(path); + std::wstring pathW = string::UTF8toUTF16(path); shExInfo.lpFile = pathW.c_str(); shExInfo.nShow = SW_SHOW;