Last active
December 3, 2016 02:02
-
-
Save christiandeange/b75d4d9e7791b7222b73 to your computer and use it in GitHub Desktop.
Full-width character converter for OS X
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
| #!/usr/bin/env python | |
| import subprocess | |
| import sys | |
| DIFF = 0xFF01 - 0x0021 | |
| def transform(c): | |
| i = ord(c) | |
| if i >= 0x21 and i <= 0xFE: | |
| return unichr(DIFF + i) | |
| elif i == ord(' '): | |
| return unichr(0x3000) | |
| else: | |
| return unichr(i) | |
| if len(sys.argv) > 1: | |
| input = ' '.join(sys.argv[1:]) | |
| else: | |
| input = sys.stdin.readlines() | |
| output = ''.join(map(transform, input)).encode('utf-8') | |
| print output | |
| subprocess.Popen(['pbcopy', 'w'], stdin=subprocess.PIPE, close_fds=True).communicate(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment