Logo Search packages:      
Sourcecode: calibre version File versions

def calibre::ebooks::rtf2xml::hex_2_utf8::Hex2Utf8::__hex_text_func (   self,
  line 
) [private]

Required:
    'line' -- the line
Logic:
    get the hex_num and look it up in the default dictionary. If the
    token is in the dictionary, then check if the value starts with a
    "&". If it does, then tag the result as utf text. Otherwise, tag it
    as normal text.
    If the nex_num is not in the dictionary, then a mistake has been
    made.
    

Definition at line 212 of file hex_2_utf8.py.

00212                                    :
        """
        Required:
            'line' -- the line
        Logic:
            get the hex_num and look it up in the default dictionary. If the
            token is in the dictionary, then check if the value starts with a
            "&". If it does, then tag the result as utf text. Otherwise, tag it
            as normal text.
            If the nex_num is not in the dictionary, then a mistake has been
            made.
            """
        hex_num = line[17:-1]
        converted = self.__current_dict.get(hex_num)
        if converted != None:
            # tag as utf-8
            if converted[0:1] == "&":
                font = self.__current_dict_name
                if self.__convert_caps\
                and self.__caps_list[-1] == 'true'\
                and font != 'Symbol'\
                and font != 'Wingdings'\
                and font != 'Zapf Dingbats':
                    converted = self.__utf_token_to_caps_func(converted)
                self.__write_obj.write(
                'tx<ut<__________<%s\n' % converted
                )
            # tag as normal text
            else:
                font = self.__current_dict_name
                if self.__convert_caps\
                and self.__caps_list[-1] == 'true'\
                and font != 'Symbol'\
                and font != 'Wingdings'\
                and font != 'Zapf Dingbats':
                    converted = converted.upper()
                self.__write_obj.write(
                'tx<nu<__________<%s\n' % converted
                )
        # error
        else:
            token = hex_num.replace("'", '')
            the_num = 0
            if  token:
                the_num = int(token, 16)
            if the_num > 10:
                self.__write_obj.write('mi<tg<empty-att_<udef_symbol<num>%s<description>not-in-table\n' %
                    hex_num)
                if self.__run_level > 4:
                    # msg = 'no dictionary entry for %s\n'
                    # msg += 'the hexidecimal num is "%s"\n' % (hex_num)
                    # msg += 'dictionary is %s\n' % self.__current_dict_name
                    msg = 'Character "&#x%s;" does not appear to be valid (or is a control character)\n' % token
                    raise self.__bug_handler, msg
    def __found_body_func(self, line):


Generated by  Doxygen 1.6.0   Back to index