#!/usr/bin/env python # From The Unicode Standard v5.0, Section 3.12 SBase = 0xAC00 LBase = 0x1100 VBase = 0x1161 TBase = 0x11A7 SCount = 11172 LCount = 19 VCount = 21 TCount = 28 NCount = VCount * TCount def decompose(char): S = ord(char) SIndex = S - SBase if (0 <= SIndex) and (SIndex < SCount): L = LBase + SIndex / NCount V = VBase + (SIndex % NCount) / TCount T = TBase + SIndex % TCount if T == TBase: return (unichr(L), unichr(V)) else: return (unichr(L), unichr(V), unichr(T)) def main(): pass if __name__ == '__main__': main()