UTF-8: Elbow, Tee, Pipe, Blank

#!/usr/bin/python3 # ==================================================================== # UTF-8 strings: elbow, tee, pipe, blank # ==================================================================== def utf8len(s): return len(s.encode('utf-8')) # --------- s = '└──' print() print(f"elbow ({s}) len={len(s)} chars len={utf8len(s)} bytes") for c in s: print(f'({c}) is {ord(c):<4} ord={hex(ord(c)):<4}') # --------- s = '├──' print() print(f"tee ({s}) len={len(s)} chars len={utf8len(s)} bytes") for c in '├──': print(f'({c}) is {ord(c):<4} ord={hex(ord(c)):<4}') # --------- s = '│ ' print() print(f"pipe ({s}) len={len(s)} chars len={utf8len(s)} bytes") for c in '│ ': print(f'({c}) is {ord(c):<4} ord={hex(ord(c)):<4}') # --------- s = ' ' print() print(f"blank ({s}) len={len(s)} chars len={utf8len(s)} bytes") for c in ' ': print(f'({c}) is {ord(c):<4x} ord={hex(ord(c)):<4}')