#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict

def encodings():
    '''http://stackoverflow.com/a/1728414/874188'''
    import pkgutil
    import encodings

    exclude=set(['aliases',
        # Exclude binary encodings, ascii encodings, reserved encodings, etc
        'bz2_codec', 'punycode', 'hex_codec', 'uu_codec', 'unicode_internal',
        'quopri_codec', 'raw_unicode_escape', 'unicode_escape', 'base64_codec',
        'zlib_codec', 'charmap', 'ascii', 'string_escape', 'rot_13',
        'undefined', 'idna',
        # Exclude multi-byte encodings: UTF-xx
        'mbcs', 'utf_7', 'utf_8', 'utf_8_sig',
        'utf_16', 'utf_16_be', 'utf_16_le',
        'utf_32', 'utf_32_be', 'utf_32_le',
        # Chinese
        'big5hkscs', 'gbk', 'gb2312', 'hz', 'big5', 'gb18030', 'cp950',
        # Japanese
        'euc_jp', 'euc_jisx0213', 'euc_jis_2004',
        'iso2022_jp', 'iso2022_jp_ext', 'iso2022_jp_1',
        'iso2022_jp_2', 'iso2022_jp_3', 'iso2022_jp_2004',
        'shift_jis', 'shift_jis_2004', 'shift_jisx0213', 'cp932',
        # Korean
        'euc_kr', 'iso2022_kr', 'johab', 'cp949'])

    found=set(name for im, name, ispkg in
        pkgutil.iter_modules(encodings.__path__))
    exclude = exclude.union(set(encodings.aliases.aliases.keys()))
    found.difference_update(exclude)
    return found

codecs = encodings()
result = dict()

for ch in xrange(128,256,1):
    print("0x%02x" % ch)
    char = chr(ch)
    result[ch] = defaultdict(list)
    for enc in codecs:
        try:
            code = char.decode(enc)
            result[ch][code].append(enc)
        except UnicodeDecodeError, err:
            if 'character maps to <undefined>' in err:
                result[ch]['undefined'].append(enc)
            else:
                raise
    for glyph in sorted(result[ch].keys()):
        if glyph == 'undefined':
            continue
        print(("  %s (%r): %s" % (glyph, glyph,
            ", ".join(sorted(result[ch][glyph])))).encode('utf-8'))
    if 'undefined' in result[ch]:
        print("  (undefined): %s" % ", ".join(result[ch]['undefined']))
    print("")

@@ -76,16 +76,81 @@
 ultdict%0A
+from textwrap import TextWrapper%0A%0A%0Awrap=True   # edit to change%0A%0A
 %0Adef enc
@@ -1418,16 +1418,237 @@
  found%0A%0A
+%0Adef wraplines (lines):%0A    t = TextWrapper(initial_indent=lines%5B0%5D,%0A        subsequent_indent=' ' * len(lines%5B0%5D))%0A    return '%5Cn'.join(t.wrap(*lines%5B1:%5D))%0A%0A%0Aif wrap:%0A    wrapper=wraplines%0Aelse:%0A    wrapper=lambda x: x%0A%0A
 codecs =
@@ -2197,18 +2197,26 @@
   print(
-(%22
+wrapper(%5B'
   %25s (%25r
@@ -2218,19 +2218,17 @@
 s (%25r): 
-%25s%22
+'
  %25 (glyp
@@ -2235,16 +2235,17 @@
 h, glyph
+)
 ,%0A      
@@ -2250,20 +2250,20 @@
         
-%22, %22
+', '
 .join(so
@@ -2286,17 +2286,17 @@
 glyph%5D))
-)
+%5D
 ).encode
@@ -2354,17 +2354,26 @@
   print(
-%22
+wrapper(%5B'
   (undef
@@ -2383,24 +2383,40 @@
 d): 
-%25s%22 %25 %22, %22
+',%0A            ', '
 .join(
+sorted(
 resu
@@ -2436,16 +2436,35 @@
 ined'%5D))
+%5D).encode('utf-8'))
 %0A    pri
@@ -2470,8 +2470,8 @@
 int(
-%22%22
+''
 )%0A

Add wrapping