Created
April 14, 2018 21:21
-
-
Save iacchus/cb7c2277c48886edaa7a945109810f0c to your computer and use it in GitHub Desktop.
widen_ascii.py
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 python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
WIDE_MAP = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F)) | |
WIDE_MAP[0x20] = 0x3000 | |
def widen(s): | |
""" | |
Convert all ASCII characters to the full-width counterpart. | |
>>> print widen('test, Foo!') | |
test, Foo! | |
>>> | |
""" | |
return s.translate(WIDE_MAP) | |
#while True: | |
# line = sys.stdin.readline() | |
# if not line: break | |
# sys.stdout.write(widen(line.decode('utf-8')).encode('utf-8')) | |
#print(widen('the wizards club')) | |
#print(widen('imlabs')) | |
print(widen(str(sys.stdin.read()))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment