#!/usr/bin/env python3 # -*- coding: utf-8 -*- from __future__ import division, generators, print_function, with_statement r"""Starting file for creating a Python module. file listutf8.py function listutf8 purpose list all Unicode code point values with UTF-8 octets syntax listutf8 email 11054987560151472272755686915985840251291393453694611309 """ #-------.-------.-------.-------.-------.-------.-------.-------.-------.-------. __license__ = r""" Copyright © 2018, by Phil D. Howard - all other rights reserved Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. The author may be contacted by decoding the number 11054987560151472272755686915985840251291393453694611309 (provu igi la numeron al duuma) """ #-------.-------.-------.-------.-------.-------.-------.-------.-------.------- import os #from decimal import Decimal from sys import argv, stderr, stdin, stdout, version_info from time import sleep, strftime, time as secs from to_utf8 import to_utf8 from un_utf8 import un_utf8 from to_fixed_base import to_fixed_base try: if 'nodebug' in os.environ: def sl(*a,**o): return def pr(*a,**o): return def pv(*a,**o): return else: from d import sl, pr, pv except ImportError: def sl(*a,**o): return def pr(*a,**o): return def pv(*a,**o): return #-------.-------.-------.-------.-------.-------.-------.-------.-------.------- unicodemin = 0 unicodemax = 0x110000 def eprint(*a,**o): if 'file' not in o: o['file']=stderr r=print(*a,**o) o['file'].flush() return r def oprint(*a,**o): if 'file' not in o: o['file']=stdout r=print(*a,**o) o['file'].flush() return r def help(): eprint('scream loudly for help') return def version(): eprint('version la.la.la') return def main(args): errors = 0 cmdname = args.pop(0) opts = set([]) if 'h' in opts: return help() if 'v' in opts: return version() files = [open(str(x+1),'wb')for x in range(8)] lenfiles = len(files) for point in range(unicodemin,unicodemax): utf = to_utf8(point,modified=False) lenutf = len(utf) org = un_utf8(utf) if isinstance(org,(list,tuple)) and len(org) == 1 and isinstance(org[0],int): org = org[0] if org != point: raise ValueError(f'converted {point!r} to UTF-8 {utf!r} which failed to convert back, got {org!r}') if point < 0x10000: out = 'U+'+hex(point+0x10000)[-4:].upper() else: out = 'U+'+hex(point)[2:].upper() out += ' ' out += '('+str(point)+')' out += ' = ' out += ' '.join(hex(b+0x100)[-2:].upper() for b in utf) if point < unicodemax and chr(point).isprintable(): s = ''.join(chr(x)for x in utf) if point == 92: # is \? s = s+s # is \\ out += ' : ' out += s if lenutf <= lenfiles: b = bytes(ord(x)for x in out) + b'\n' files[lenutf-1].write(b) for f in files: f.close() return 0 #-------.-------.-------.-------.-------.-------.-------.-------.-------.------- if __name__ == '__main__': from sys import argv, stderr, stdin, stdout, version_info if bytes == str: BrokenPipeError, FileNotFoundError = IOError, OSError try: result = main(argv) except BrokenPipeError: result = 99 except KeyboardInterrupt: stderr.flush() print() result = 98 try: stderr.flush() except: pass try: stdout.flush() except: pass if result == 0 or result is None or result is True: exit(0) if result == 1 or result is False: exit(1) if isinstance(result,str): print(result,file=stderr) stderr.flush() exit(2) try: exit(int(result)) except ValueError: print(str(result),file=stderr) stderr.flush() exit(3) except TypeError: exit(4) # EOF #-------.-------.-------.-------.-------.-------.-------.-------.-------.-------