-
-
Save Nyubis/96e6da3ad52c20ad4524f64116b5267d to your computer and use it in GitHub Desktop.
fullwidth shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# script for converting text to fullwidth characters on the clipboard | |
# don't try to enter anything that doesn't have a fullwidth equivalent | |
# usage: fw test | |
# result: the clipboard now contains test | |
words=$* | |
for (( i=0; i<${#words}; i++ )); do | |
char="${words:$i:1}" | |
if [[ "${char}" == " " ]]; then | |
# for some reason, the ideographic space is not in the fullwidth block | |
# the mysteries of unicode, I suppose. | |
printf " " | |
else | |
# handle characters that aren't spaces, transforming them | |
# into their fullwidth equivalent (hope they have it) | |
codepoint=$(printf '%x' "'$char") | |
fwcp=$(printf '\\uFF%02x' $((0x$codepoint - 0x20))) | |
printf $fwcp | |
fi | |
done | xsel -ib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment