[PR #1340] [MERGED] Use UTF8 internally and convert to UTF16 at the edge. #1779

Closed
opened 2026-05-05 08:01:45 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/debauchee/barrier/pull/1340
Author: @p12tic
Created: 10/29/2021
Status: Merged
Merged: 10/29/2021
Merged by: @p12tic

Base: masterHead: use-utf8


📝 Commits (3)

  • 15a955f Revert "Use ansi codepage for internal multibyte strings on windows"
  • 8286c85 lib/common/win32: Extract unicode_to_mb() to separate file
  • d24f368 Correctly open files with non-ASCII paths on Windows

📊 Changes

21 files changed (+241 additions, -155 deletions)

View changed files

📝 src/gui/src/CommandProcess.cpp (+10 -11)
📝 src/gui/src/Fingerprint.cpp (+5 -2)
📝 src/gui/src/IpcClient.cpp (+5 -3)
📝 src/gui/src/MainWindow.cpp (+2 -1)
📝 src/gui/src/QUtility.cpp (+0 -9)
📝 src/gui/src/QUtility.h (+0 -1)
📝 src/gui/src/SslCertificate.cpp (+26 -21)
📝 src/gui/src/SslCertificate.h (+4 -4)
📝 src/lib/barrier/DropHelper.cpp (+2 -1)
📝 src/lib/barrier/win32/DaemonApp.cpp (+1 -2)
📝 src/lib/base/log_outputters.cpp (+2 -2)
📝 src/lib/common/win32/DataDirectories.cpp (+17 -3)
src/lib/common/win32/KnownFolderPaths.cpp (+0 -63)
src/lib/common/win32/KnownFolderPaths.h (+0 -24)
src/lib/common/win32/encoding_utilities.cpp (+37 -0)
src/lib/common/win32/encoding_utilities.h (+28 -0)
src/lib/io/fstream.cpp (+57 -0)
src/lib/io/fstream.h (+35 -0)
📝 src/lib/ipc/IpcLogOutputter.cpp (+1 -2)
📝 src/lib/net/SecureSocket.cpp (+2 -1)

...and 1 more files

📄 Description

On Windows the standard stream open() functions expect bytes encoded in current system encoding, not UTF8. Since we're dealing with UTF8 throughout the application this results in wrong paths being passed and failure to open files. As a solution, we convert the paths to UTF16 via the WCHAR character type and use the special Windows-specific overloads of open() functions.

Previous solution was making half of application to use local encodings which made the system hard to understand and very brittle.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/debauchee/barrier/pull/1340 **Author:** [@p12tic](https://github.com/p12tic) **Created:** 10/29/2021 **Status:** ✅ Merged **Merged:** 10/29/2021 **Merged by:** [@p12tic](https://github.com/p12tic) **Base:** `master` ← **Head:** `use-utf8` --- ### 📝 Commits (3) - [`15a955f`](https://github.com/debauchee/barrier/commit/15a955ff2139c2cc94f382135f8d412c50b74b75) Revert "Use ansi codepage for internal multibyte strings on windows" - [`8286c85`](https://github.com/debauchee/barrier/commit/8286c85dc0722e99273f7f2d7a2375cbc830cc84) lib/common/win32: Extract unicode_to_mb() to separate file - [`d24f368`](https://github.com/debauchee/barrier/commit/d24f368efe9a1b4edb6a56f4ee53bdc817edde91) Correctly open files with non-ASCII paths on Windows ### 📊 Changes **21 files changed** (+241 additions, -155 deletions) <details> <summary>View changed files</summary> 📝 `src/gui/src/CommandProcess.cpp` (+10 -11) 📝 `src/gui/src/Fingerprint.cpp` (+5 -2) 📝 `src/gui/src/IpcClient.cpp` (+5 -3) 📝 `src/gui/src/MainWindow.cpp` (+2 -1) 📝 `src/gui/src/QUtility.cpp` (+0 -9) 📝 `src/gui/src/QUtility.h` (+0 -1) 📝 `src/gui/src/SslCertificate.cpp` (+26 -21) 📝 `src/gui/src/SslCertificate.h` (+4 -4) 📝 `src/lib/barrier/DropHelper.cpp` (+2 -1) 📝 `src/lib/barrier/win32/DaemonApp.cpp` (+1 -2) 📝 `src/lib/base/log_outputters.cpp` (+2 -2) 📝 `src/lib/common/win32/DataDirectories.cpp` (+17 -3) ➖ `src/lib/common/win32/KnownFolderPaths.cpp` (+0 -63) ➖ `src/lib/common/win32/KnownFolderPaths.h` (+0 -24) ➕ `src/lib/common/win32/encoding_utilities.cpp` (+37 -0) ➕ `src/lib/common/win32/encoding_utilities.h` (+28 -0) ➕ `src/lib/io/fstream.cpp` (+57 -0) ➕ `src/lib/io/fstream.h` (+35 -0) 📝 `src/lib/ipc/IpcLogOutputter.cpp` (+1 -2) 📝 `src/lib/net/SecureSocket.cpp` (+2 -1) _...and 1 more files_ </details> ### 📄 Description On Windows the standard stream open() functions expect bytes encoded in current system encoding, not UTF8. Since we're dealing with UTF8 throughout the application this results in wrong paths being passed and failure to open files. As a solution, we convert the paths to UTF16 via the WCHAR character type and use the special Windows-specific overloads of open() functions. Previous solution was making half of application to use local encodings which made the system hard to understand and very brittle. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 08:01:45 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/barrier#1779
No description provided.