b.cache_utf8 : module documentation

Part of bzrlib

Some functions to enable caching the conversion between unicode to utf8
Function encode Take this unicode revision id, and get a unicode version
Function decode Take a utf8 revision id, and decode it, but cache the result
Function get_cached_unicode Return a cached version of the unicode string.
Function get_cached_utf8 Return a cached version of the utf-8 string.
Function get_cached_ascii This is a string which is identical in utf-8 and unicode.
Function clear_encoding_cache Clear the encoding and decoding caches
Function _utf8_decode_with_None wrap _utf8_decode to support None->None for optional strings.
def _utf8_decode_with_None(bytestring, _utf8_decode=_utf8_decode):
wrap _utf8_decode to support None->None for optional strings.

Also, only return the Unicode portion, since we don't care about the second return value.

def encode(unicode_str, _uni_to_utf8=_unicode_to_utf8_map, _utf8_to_uni=_utf8_to_unicode_map, _utf8_encode=_utf8_encode):
Take this unicode revision id, and get a unicode version
def decode(utf8_str, _uni_to_utf8=_unicode_to_utf8_map, _utf8_to_uni=_utf8_to_unicode_map, _utf8_decode=_utf8_decode):
Take a utf8 revision id, and decode it, but cache the result
def get_cached_unicode(unicode_str):
Return a cached version of the unicode string.

This has a similar idea to that of intern() in that it tries to return a singleton string. Only it works for unicode strings.

def get_cached_utf8(utf8_str):
Return a cached version of the utf-8 string.

Get a cached version of this string (similar to intern()). At present, this will be decoded to ensure it is a utf-8 string. In the future this might change to simply caching the string.

def get_cached_ascii(ascii_str, _uni_to_utf8=_unicode_to_utf8_map, _utf8_to_uni=_utf8_to_unicode_map):
This is a string which is identical in utf-8 and unicode.
def clear_encoding_cache():
Clear the encoding and decoding caches
API Documentation for Bazaar, generated by pydoctor at 2022-06-16 00:25:16.