Skip to content

Instantly share code, notes, and snippets.

@iacchus
Created April 14, 2018 21:21
Show Gist options
  • Save iacchus/cb7c2277c48886edaa7a945109810f0c to your computer and use it in GitHub Desktop.
Save iacchus/cb7c2277c48886edaa7a945109810f0c to your computer and use it in GitHub Desktop.
widen_ascii.py
#!/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