def cleanup_command_line():
if not sys.stdin.encoding or sys.stdin.encoding == 'ascii':
return
conversion_pairs = {
'EN DASH': '-',
'EM DASH': '--',
'LEFT DOUBLE QUOTATION MARK': '"',
'RIGHT DOUBLE QUOTATION MARK': '"',
'LEFT SINGLE QUOTATION MARK': "'",
'RIGHT SINGLE QUOTATION MARK': "'",
}
for i in range(len(sys.argv)):
# create a unicode string with the decoded contents of the corresponding
# sys.argv string
decoded = unicode(sys.argv[i], sys.stdin.encoding)
for key, val in conversion_pairs.iteritems():
decoded = unicode.replace(decoded, unicodedata.lookup(key), val)
# Should we be doing 'strict' here instead of 'replace'?
sys.argv[i] = decoded.encode(sys.stdin.encoding, 'replace')
评论列表
文章目录