You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the LANG environment variable is empty on macOS, the runtime.ClipboardGetText function in Go Wails returns incorrectly encoded text (often mojibake) from the clipboard. This issue occurs because the underlying pbpaste command relies on the LANG environment variable to determine the correct character encoding. If LANG is not set, pbpaste defaults to an encoding that is incompatible with UTF-8, leading to incorrect text when the Go Wails application expects UTF-8.
This issue only appears in released (packaged) versions of the application. In development mode, the LANG environment variable is typically inherited from the terminal, so the problem does not occur.
To Reproduce
Create a Go Wails application that uses the runtime.ClipboardGetText function to read text from the clipboard.
Ensure the macOS system is configured such that the LANG environment variable is not set in the application's environment. This can be achieved by building a release version and running it as a standalone application (i.e., not from a terminal that sets the LANG variable).
Copy text containing non-ASCII characters (e.g., Chinese, Japanese, accented characters) to the clipboard.
Paste the text into the Go Wails application using the clipboard functionality.
Observe that the text is displayed as mojibake or otherwise incorrectly encoded.
Expected behaviour
The runtime.ClipboardGetText function should always return correctly encoded text from the clipboard, regardless of the LANG environment variable. It should either:
Correctly handle cases where LANG is not set.
Ensure that the application has a valid LANG environment variable set (e.g., by setting it programmatically or in the application's Info.plist).
Alternatively, you can easily observe the behavior of the pbpaste command using the following command:
Screenshots
No response
Attempted Fixes
No response
System Details
# Wails
Version | v2.9.3
# System
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS | MacOS || Version | 15.3.1 || ID | 24D70 || Go Version | go1.23.3 || Platform | darwin || Architecture | amd64 || CPU | Apple M4 || GPU | Chipset Model: Apple M4 Type: GPU Bus: Built-In Total Number of Cores: 10 Vendor: Apple (0x106b) Metal Support: Metal 3 || Memory | 16GB |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
# Dependencies
┌────────────────────────────────────────────────────────────────┐
| Dependency | Package Name | Status | Version || Xcode command line tools | N/A | Installed | 2409 || Nodejs | N/A | Installed | 22.11.0 || npm | N/A | Installed | 10.9.0 ||*Xcode | N/A | Available |||*upx | N/A | Available |||*nsis | N/A | Available ||
└─────────────────── * - Optional Dependency ────────────────────┘
# Diagnosis
Optional package(s) installation details:
- Xcode: Available at https://apps.apple.com/us/app/xcode/id497799835
- upx : Available at https://upx.github.io/
- nsis : More info at https://wails.io/docs/guides/windows-installer/
SUCCESS Your system is ready for Wails development!
♥ If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony
Additional context
No response
The text was updated successfully, but these errors were encountered:
Description
When the LANG environment variable is empty on macOS, the runtime.ClipboardGetText function in Go Wails returns incorrectly encoded text (often mojibake) from the clipboard. This issue occurs because the underlying pbpaste command relies on the LANG environment variable to determine the correct character encoding. If LANG is not set, pbpaste defaults to an encoding that is incompatible with UTF-8, leading to incorrect text when the Go Wails application expects UTF-8.
This issue only appears in released (packaged) versions of the application. In development mode, the LANG environment variable is typically inherited from the terminal, so the problem does not occur.
To Reproduce
Ensure the macOS system is configured such that the LANG environment variable is not set in the application's environment. This can be achieved by building a release version and running it as a standalone application (i.e., not from a terminal that sets the LANG variable).
Expected behaviour
The runtime.ClipboardGetText function should always return correctly encoded text from the clipboard, regardless of the LANG environment variable. It should either:
Correctly handle cases where LANG is not set.
Ensure that the application has a valid LANG environment variable set (e.g., by setting it programmatically or in the application's Info.plist).
The code is here
Alternatively, you can easily observe the behavior of the pbpaste command using the following command:
Screenshots
No response
Attempted Fixes
No response
System Details
Additional context
No response
The text was updated successfully, but these errors were encountered: