(self, uc, errors='ignore')
Convert NFC unicode cluster to codepage char sequence.
Convert NFC unicode cluster to codepage char sequence.
Convert NFC unicode cluster to codepage char sequence .
def _from_unicode(self, uc, errors='ignore'):
        """Convert NFC unicode cluster to codepage char sequence."""
        # pass through eascii clusters
        if uc.startswith(u'\0'):
            return b''.join(int2byte(min(255, ord(c))) for c in uc)
        try:
            return self._inverse_substitutes[uc]
        except KeyError:
            pass
        try:
            # try to codepage-encode the unicode char
            return self._unicode_to_cp[uc]
        except KeyError:
            # pass control sequences as ascii. this includes \r.
            # control sequences are not in the dictionary
            # because it holds their graphical replacement characters.
            # ignore/raise/replace everything else (unicode chars not in codepage)
            return uc.encode('ascii', errors=errors)
def _from_unicode ( self , uc , errors = 'ignore' ) : # pass through eascii clusters if uc . startswith ( u'\0' ) : return b'' . join ( int2byte ( min ( 255 , ord ( c ) ) ) for c in uc ) try : return self . _inverse_substitutes [ uc ] except KeyError : pass try : # try to codepage-encode the unicode char return self . _unicode_to_cp [ uc ] except KeyError : # pass control sequences as ascii. this includes \r. # control sequences are not in the dictionary # because it holds their graphical replacement characters. # ignore/raise/replace everything else (unicode chars not in codepage) return uc . encode ( 'ascii' , errors = errors )