deseven/iCanHazShortcut

Character Encoding issue

cvickery opened this issue · 3 comments

If the text involved is not ASCII, it seems to get mangled.

For example if the shortcut is echo “iCanHazShortcut” | pbcopy then pasting gives ‚ÄúiCanHazShortcut‚Äù because the UTF-8 curly quotes at the beginning and end of the echo string are treated, erroneously, as ASCII.

If the shortcut is typed into the shell, it works correctly, and preceding the shortcut definition with LANG=en_US.UTF-8 in iCanHasShortcut setup seems to make no difference.

Pipes create subshells, so if you want to set LANG explicitly it should be done in both shells you spawn:
LANG=en_US.UTF-8 echo “iCanHazShortcut” | LANG=en_US.UTF-8 pbcopy

But first declaration can be omitted because echo actually doesn't care about encodings:
echo “iCanHazShortcut” | LANG=en_US.UTF-8 pbcopy

However, I recommend setting your locale variables through your shell config file (.bash_profile or similar), add this:

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

After that all commands you input in iCHS will use the desired locale parameters.

I usually just call locale that quickly shows all related variables.
You're welcome! Closing this.