1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WSLのclip.exeの文字化け対処

Last updated at Posted at 2023-11-21

気が向いから書いた

clip.exeとは

Windowsでのコピペをしてくれるやつ
WSLでもpathが通っている。

echo "test" | clip.exe

みたいな感じでパイプをつないであげるとクリップボードにtestが保存される

問題

clip.exeをパイプラインで使用すると日本語が文字化けするようになった。
ex)

echo "てすと" | clip.exe # クリップボードの中身が "縺ヲ縺吶→" となる(文字化けする)

対処法

以下のようなエイリアスを取ってあげればいい
alias clip.exe='iconv -t sjis | clip.exe'

エイリアスの保持のため設定を書き込む

#zshだと~/.bashrcを~/.zshrcに置き換える
echo "alias clip.exe='iconv -t sjis | clip.exe'" >> ~/.bashrc 
source ~/.bashrc 

これで文字化けは起こらなくなるはずです

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?