Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to handle utf-8 #26

Open
themadsens opened this issue Sep 20, 2017 · 3 comments
Open

Unable to handle utf-8 #26

themadsens opened this issue Sep 20, 2017 · 3 comments

Comments

@themadsens
Copy link

themadsens commented Sep 20, 2017

It seems that lemonade cannot handle utf-8 in and out of the clipboard. At least on MacOS.

As long as lemonade is used for both directions it seems OK, but using pbcopy or the system 'Copy' or 'Paste' in conjunction does not work

image

OS data according to screenfetch
OS: 64bit Mac OS X 10.12.6 16G29
Kernel: x86_64 Darwin 16.7.0

In binary

[fmmbp thm-dotfiles]$ echo 'Blåbærgrød' | pbcopy
[fmmbp thm-dotfiles]$ pbpaste | hexdump -C
00000000  42 6c c3 a5 62 c3 a6 72  67 72 c3 b8 64 0a        |Bl..b..rgr..d.|
0000000e
[fmmbp thm-dotfiles]$ lemonade paste | hexdump -C
00000000  42 6c 8c 62 be 72 67 72  bf 64 0a                 |Bl.b.rgr.d.|
0000000b
[fmmbp thm-dotfiles]$ echo 'Blåbærgrød' | hexdump -C
00000000  42 6c c3 a5 62 c3 a6 72  67 72 c3 b8 64 0a        |Bl..b..rgr..d.|
0000000e
[fmmbp thm-dotfiles]$ echo 'Blåbærgrød' | lemonade copy
[fmmbp thm-dotfiles]$ pbpaste | hexdump -C
00000000  42 6c e2 88 9a e2 80 a2  62 e2 88 9a c2 b6 72 67  |Bl......b.....rg|
00000010  72 e2 88 9a e2 88 8f 64  0a                       |r......d.|
00000019
[fmmbp thm-dotfiles]$ lemonade paste | hexdump -C
00000000  42 6c c3 a5 62 c3 a6 72  67 72 c3 b8 64 0a        |Bl..b..rgr..d.|
0000000e
@mattn
Copy link
Member

mattn commented Dec 9, 2018

Go's runtime is not affected by the locale. So if the binary is changed, there migit be caused by pbcopy or pbpaste. I guess that it is the locale of the server is C or latin-1.

@mattn mattn closed this as completed Dec 9, 2018
@mattn mattn reopened this Dec 9, 2018
@jinmiaoluo
Copy link

Hey, guys.
I suffer the same problem. If you use Supervisord as your local process manager you should add some environment variables into supervisord.ini to fix the encoding problem.
example:

[supervisord]
...
environment=LC_ALL=en_US.UTF-8,LANG=en_US.UTF-8

result:
https://asciinema.org/a/u03PdoBOdySt4kiGvz0sYWSuT

@yuchanns
Copy link

yuchanns commented Mar 9, 2022

For people who uses MacOS as the server and manage the process by launchctl, you may want to add a environment.plist in ~/Library/LaunchAgents with the content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>environment</string>
  <key>ProgramArguments</key>
  <array>
    <string>sh</string>
    <string>-c</string>
    <string>
        <!-- Add locale category for native language -->
        <!-- For me, it's zh-CN.UTF-8 -->
        launchctl setenv LANG zh_CN.UTF-8
        launchctl setenv LC_ALL zh_CN.UTF-8
    </string>

  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>

Then load it by launchctl load environment.plist. It works now.

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

No branches or pull requests

4 participants