Skip to content

Instantly share code, notes, and snippets.

@typeon
Created July 28, 2016 11:27
Show Gist options
  • Select an option

  • Save typeon/6eeeba75354ecfb476dcb96ec58125f6 to your computer and use it in GitHub Desktop.

Select an option

Save typeon/6eeeba75354ecfb476dcb96ec58125f6 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
import sys
print('current cmd encoding : ', sys.stdout.encoding)
# - ー, ・, 収, 録, 覧 - UnicodeEncodeError: cp949 codec cannot encode char.
#
str = 'ー ・ このグリフを収録するグループおよび引用するドキュメント一覧'
if sys.stdout.encoding != 'utf-8':
print(str.encode(sys.stdout.encoding, 'replace').decode(sys.stdout.encoding, 'replace'))
else:
print(str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment