Skip to content

Fix clipboard encoding issue on WSL#59

Merged
sammcj merged 3 commits intosammcj:mainfrom
MustafaKrc:main
Jan 17, 2026
Merged

Fix clipboard encoding issue on WSL#59
sammcj merged 3 commits intosammcj:mainfrom
MustafaKrc:main

Conversation

@MustafaKrc
Copy link
Copy Markdown
Contributor

I am using this tool on a Windows 11 machine inside a WSL2 Ubuntu distribution.

Ingestion mechanism works as intended, however copying to clipboard does not work properly. Unicode characters are not properly copied to clipboard. Example in figure below:

image

With these changes:

  • If WSL is detected, the code attempts to use PowerShell with utf-8 encoding to copy to clipboard.
  • If it fails to use PowerShell, it fallbacks to previous method of copying to clipboard.

Here is working example:
image

@sammcj sammcj requested a review from Copilot November 26, 2025 23:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Unicode encoding issues when copying to clipboard on Windows Subsystem for Linux (WSL) by implementing a WSL-specific clipboard handler that uses PowerShell with UTF-8 encoding.

Key Changes:

  • Adds WSL detection logic using environment variables and kernel information
  • Implements PowerShell-based clipboard writing for WSL with UTF-8 encoding support
  • Provides fallback to the original clipboard method if PowerShell fails

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@MustafaKrc
Copy link
Copy Markdown
Contributor Author

Copilot made valid points. I have updated writeToWindowsClipboard function accordingly

@sammcj sammcj self-assigned this Jan 17, 2026
Copy link
Copy Markdown
Owner

@sammcj sammcj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks! Sorry for the delay

@sammcj sammcj merged commit 75f9c9e into sammcj:main Jan 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants