Return the Unicode block of the given Unicode character
169809
def get(cls, uni_char):
        """"""
        uni_char = unicod(uni_char)  # Force to Unicode
        code_point = ord(uni_char)
        if Block._RANGE_KEYS is None:
            Block._RANGE_KEYS = sorted(Block._RANGES.keys())
        idx = bisect.bisect_left(Block._RANGE_KEYS, code_point)
        if (idx > 0 and
            code_point >= Block._RANGES[Block._RANGE_KEYS[idx - 1]].start and
            code_point <= Block._RANGES[Block._RANGE_KEYS[idx - 1]].end):
            return Block._RANGES[Block._RANGE_KEYS[idx - 1]]
        elif (idx < len(Block._RANGES) and
              code_point >= Block._RANGES[Block._RANGE_KEYS[idx]].start and
              code_point <= Block._RANGES[Block._RANGE_KEYS[idx]].end):
            return Block._RANGES[Block._RANGE_KEYS[idx]]
        else:
            return Block.UNKNOWN
561089
def pad_char(text: str, width: int, char: str = '\n') -> str:
    """"""
    dis = width - len(text)
    if dis < 0:
        raise ValueError
    if dis > 0:
        text += char * dis
    return text
936878
def _load_unicode_block_info(self):
        
        filename = "Blocks.txt"
        current_dir = os.path.abspath(os.path.dirname(__file__))
        with codecs.open(os.path.join(current_dir, filename), mode="r", encoding="utf-8") as fp:
            for line in fp:
                if not line.strip() or line.startswith("#"):
                    continue  # Skip empty lines or lines that are comments (comments start with '#')
                # Format: Start Code..End Code; Block Name
                block_range, block_name = line.strip().split(";")
                start_range, end_range = block_range.strip().split("..")
                self._unicode_blocks[six.moves.range(int(start_range, 16), int(end_range, 16) + 1)] = block_name.strip()
1058906
def _get_token_type(self, char):
        
        if char in '()':
            return self.SPLIT, 0
        elif char == ',':
            return self.SPLIT, 1
        elif char in '<>':
            return self.IGNORE, 2
        elif char == '.':
            return self.JOIN, 3
        elif char.isdigit():
            return self.JOIN, 4
        elif char.isalpha():
            return self.JOIN, 5
        elif char == '^':
            return self.JOIN, 6
        elif char.isspace():
            return self.IGNORE, 7
        else:
            raise ValueError('TokeniserException: "{}" can not be tokenised'.format(char))
612231
def to_unicode_repr( _letter ):
    
    # Python 2-3 compatible
    return u"u'"+ u"".join( [ u"\\u%04x"%ord(l) for l in _letter ] ) + u"'"
372144
private static boolean isPrintableChar(char c) {
        if (Character.isISOControl(c)) { return false; }
        Character.UnicodeBlock block = Character.UnicodeBlock.of(c);
        return block != null && block != Character.UnicodeBlock.SPECIALS;
    }
1027527
def get_unicode(self):
        
        s = mutf8.decode(self.data)
        if len(s) != self.utf16_size:
            raise ValueError("UTF16 Length does not match!")

        # Return a UTF16 String
        return s
528770
def bool_to_unicode(b):
    """"""
    b = bool(b)
    if b is True:  return u"✅"
    if b is False: return u"❎"
1037880
def computeSmartIndent(self, block, char):
        
        lineText = block.text()
        prevLineText = self._prevNonEmptyBlock(block).text()

        alignOnly = char == ''

        if alignOnly:
            # XML might be all in one line, in which case we want to break that up.
            tokens = re.split(r'>\s*<', lineText)

            if len(tokens) > 1:

                prevIndent = self._lineIndent(prevLineText)

                for index, newLine in enumerate(tokens):
                    if index > 0:
                        newLine = '<' + newLine

                    if index < len(tokens) - 1:
                        newLine = newLine + '>'
                    if re.match(r'^\s*</', newLine):
                        char = '/'
                    elif re.match(r'\\>[^<>]*$', newLine):
                        char = '>'
                    else:
                        char = '\n'

                    indentation = self.processChar(newLine, prevLineText, char)
                    newLine = indentation + newLine

                    tokens[index] = newLine
                    prevLineText = newLine;

                self._qpart.lines[block.blockNumber()] =  '\n'.join(tokens)
                return None
            else:  # no tokens, do not split line, just compute indent
                if re.search(r'^\s*</', lineText):
                    char = '/'
                elif re.search(r'>[^<>]*', lineText):
                    char = '>'
                else:
                    char = '\n'

        return self.processChar(lineText, prevLineText, char)
885687
def _unicode(self):
        ''''''

        return u'\n'.join ([ u''.join(c) for c in self.w ])
220360
def get_unicode_property(value, prop=None, is_bytes=False):
    """"""

    if prop is not None:
        prop = unidata.unicode_alias['_'].get(prop, prop)
        try:
            if prop == 'generalcategory':
                return get_gc_property(value, is_bytes)
            elif prop == 'script':
                return get_script_property(value, is_bytes)
            elif prop == 'scriptextensions':
                return get_script_extension_property(value, is_bytes)
            elif prop == 'block':
                return get_block_property(value, is_bytes)
            elif prop == 'binary':
                return get_binary_property(value, is_bytes)
            elif prop == 'bidiclass':
                return get_bidi_property(value, is_bytes)
            elif prop == 'bidipairedbrackettype':
                return get_bidi_paired_bracket_type_property(value, is_bytes)
            elif prop == 'age':
                return get_age_property(value, is_bytes)
            elif prop == 'eastasianwidth':
                return get_east_asian_width_property(value, is_bytes)
            elif PY35 and prop == 'indicpositionalcategory':
                return get_indic_positional_category_property(value, is_bytes)
            elif not PY35 and prop == 'indicmatracategory':
                return get_indic_positional_category_property(value, is_bytes)
            elif prop == 'indicsyllabiccategory':
                return get_indic_syllabic_category_property(value, is_bytes)
            elif prop == 'hangulsyllabletype':
                return get_hangul_syllable_type_property(value, is_bytes)
            elif prop == 'decompositiontype':
                return get_decomposition_type_property(value, is_bytes)
            elif prop == 'canonicalcombiningclass':
                return get_canonical_combining_class_property(value, is_bytes)
            elif prop == 'numerictype':
                return get_numeric_type_property(value, is_bytes)
            elif prop == 'numericvalue':
                return get_numeric_value_property(value, is_bytes)
            elif prop == 'joiningtype':
                return get_joining_type_property(value, is_bytes)
            elif prop == 'joininggroup':
                return get_joining_group_property(value, is_bytes)
            elif prop == 'graphemeclusterbreak':
                return get_grapheme_cluster_break_property(value, is_bytes)
            elif prop == 'linebreak':
                return get_line_break_property(value, is_bytes)
            elif prop == 'sentencebreak':
                return get_sentence_break_property(value, is_bytes)
            elif prop == 'wordbreak':
                return get_word_break_property(value, is_bytes)
            elif prop == 'nfcquickcheck':
                return get_nfc_quick_check_property(value, is_bytes)
            elif prop == 'nfdquickcheck':
                return get_nfd_quick_check_property(value, is_bytes)
            elif prop == 'nfkcquickcheck':
                return get_nfkc_quick_check_property(value, is_bytes)
            elif prop == 'nfkdquickcheck':
                return get_nfkd_quick_check_property(value, is_bytes)
            elif PY37 and prop == 'verticalorientation':
                return get_vertical_orientation_property(value, is_bytes)
            else:
                raise ValueError('Invalid Unicode property!')
        except Exception:
            raise ValueError('Invalid Unicode property!')

    try:
        return get_gc_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_script_extension_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_block_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_binary_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_is_property(value, is_bytes)
    except Exception:
        pass

    try:
        return get_in_property(value, is_bytes)
    except Exception:
        pass

    raise ValueError('Invalid Unicode property!')
51880
def characters(self, numberOfCharacters):
        """"""
        return self.code[self.index:self.index + numberOfCharacters]
403340
def _allowed_char(c):
    
    c = ord(c)
    if c < 0:
        return False
    if c < 128:
        return _ascii_allowed[c]
    # Genereally allow unicodes, TODO: check for unicode control characters
    # characters
    return True
890975
def digit(uni_char, default_value=None):
    """"""
    uni_char = unicod(uni_char)  # Force to Unicode.
    if default_value is not None:
        return unicodedata.digit(uni_char, default_value)
    else:
        return unicodedata.digit(uni_char)
1275897
def get_block(self, namespace, offset, key):
        """"""
        cursor = self.cursor
        cursor.execute('SELECT data, flags FROM gauged_data '
                       'WHERE namespace = %s AND "offset" = %s AND key = %s',
                       (namespace, offset, key))
        row = cursor.fetchone()
        return (None, None) if row is None else row
1307783
def unicode2str(content):
    """"""
    if isinstance(content, dict):
        result = {}
        for key in content.keys():
            result[unicode2str(key)] = unicode2str(content[key])
        return result
    elif isinstance(content, list):
        return [unicode2str(element) for element in content]
    elif isinstance(content, int) or isinstance(content, float):
        return content
    else:
        return content.encode("utf-8")
815069
def find_next_character(code, position, char):
    """"""
    end = LineCol(code, *position)
    while not end.eof and end.char() in WHITESPACE:
        end.inc()

    if not end.eof and end.char() == char:
        return end.tuple(), inc_tuple(end.tuple())
    return None, None