
# -------------------------------------------------------------
# Unicode characters demo

def uniCharDemo( start,  end ):

    # detect incorrect input
    if start > end or start < 0 or end > 0x10FFFF:
        return

    # print all characters in the given range
    # including the end one

    print("Characters in range", start, "-", end )
    print("              range", hex(start), "-", hex(end) )

    for i in range( start, end+1 ):
        print( i, hex(i), "", chr(i) )

    # note the instance of the persistent
    # off-by-one problem: in range ( start, end+1 )


# -------------------------------------------------------------
# Example of selected sets of characters


# Degrees Celsius
print( u'\u2103 \u00b0' )

# Control characters (incl. historical ones)
# Mostly no sensible text/symbols in the output
uniCharDemo( 0, 31 )

# Standard characters
# usual space is the first (32)
uniCharDemo( 32, 127 )
uniCharDemo( 128, 255 )
# Note  the copyright symbol (169), the degree symbol (176)
# plus/minus symbol (177) and a few others.


# Greek and Coptic
uniCharDemo( 0x0370, 0x03ff )

# Cyrillic
uniCharDemo( 0x0400, 0x04ff )

# Arabic
uniCharDemo( 0x0600, 0x06ff )

# Various math symbols
uniCharDemo( 0x2200, 0x22ff )

# A few rectangular blocks
uniCharDemo( 0x2580, 0x259f )

# ... and many more


# -------------------------------------------------------------
# Additional reading

# [1]
'''
Unicode 13.0, contains a repertoire of
    143,924 characters( consisting of
    143,696 graphic characters,
        163 format characters and
         65 control characters)

covering 154 modern and historic scripts,
as well as multiple symbol sets and emoji.

[https://en.wikipedia.org/wiki/Unicode]

Unicode 13.0 defines 308 blocks:

    163 in plane 0, the Basic Multilingual Plane (BMP)
    134 in plane 1, the Supplementary Multilingual Plane (SMP)
      6 in plane 2, the Supplementary Ideographic Plane (SIP)
      2 in plane 14 (E in hexadecimal),
          the Supplementary Special-purpose Plane (SSP)
      1 in plane 3, the Tertiary Ideographic Plane (TIP)
    One each in the planes 15 (Fhex) and 16 (10hex),
       called Supplementary Private Use Area-A and -B

[https://en.wikipedia.org/wiki/Unicode_block]

'''

# [2]
# Visit
# https://en.wikipedia.org/wiki/Unicode_block
# for more examples of unicode characters.


# [3]
# Broader topics -- understanding unicode:
# https://docs.python.org/3/howto/unicode.html






