def convert_to_unicode( tscii_input ):
    """ convert a byte-ASCII encoded string into equivalent Unicode string
    in the UTF-8 notation."""
    output = list()
    prev = None
    prev2x = None
    # need a look ahead of 2 tokens atleast
    for char in tscii_input:
        ## print "%2x"%ord(char) # debugging
        if ord(char) < 128 :
            # base-ASCII copy to output
            output.append( char )
            prev = None
            prev2x = None
            
        elif ord(char) in TSCII_DIRECT_LOOKUP:
            if ( prev in TSCII_PRE_MODIFIER ):
                curr_char = [TSCII[ord(char)],TSCII[prev]]                
            else:
                # we are direct lookup char
                curr_char = [TSCII[ord(char)]]
                char = None

            output.extend( curr_char )

        elif ( (ord(char) in TSCII_POST_MODIFIER) ): 
            
            if ( (prev in TSCII_DIRECT_LOOKUP) and 
                 (prev2x in TSCII_PRE_MODIFIER) ):
                if len(output) >= 2:
                    del output[-1] #we are reducing this token to something new
                    del output[-2]
                elif len(output)==1:
                    del output[-1] 
                else:
                    # nothing to delete here.. 
                    pass
                output.extend( [TSCII[prev], TSCII[prev2x]] )
            else:
                print("Warning: malformed TSCII encoded file; skipping characters")
            
            prev = None
            char = None
        else:
            # pass - must be one of the pre/post modifiers
            pass
        
        prev2x = prev
        if char:
            prev = ord(char)
    return u"".join(output)
convert a byte-ASCII encoded string into equivalent Unicode string
    in the UTF-8 notation.