#NEWLINE# def _bisearch( ucs , table ) : #NEWLINE# #INDENT# "\n    Auxiliary function for binary search in interval table.\n\n    :param ucs: a single unicode character's ordinal value.\n    :type ucs: int\n    :param table: a lookup table of tuples in form of ``[(start, end), ...]``.\n    :type table: list\n    :rtype int\n    :returns: 1 if ordinal value ucs is found within lookup table, else 0.\n    " #NEWLINE# lbound = 0 #NEWLINE# ubound = ( len ( table ) - 1 ) #NEWLINE# if ( ( ucs < table [ 0 ] [ 0 ] ) or ( ucs > table [ ubound ] [ 1 ] ) ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# while ( ubound >= lbound ) : #NEWLINE# #INDENT# mid = ( ( lbound + ubound ) // 2 ) #NEWLINE# if ( ucs > table [ mid ] [ 1 ] ) : #NEWLINE# #INDENT# lbound = ( mid + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ucs < table [ mid ] [ 0 ] ) : #NEWLINE# #INDENT# ubound = ( mid - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return 0