~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/cache_utf8.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-08 23:10:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070208231037-xzuzlh339rmgfhk6
Add a get_cached_utf8, which will ensure it is really utf8, and cache the strings

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
    return decode(encode(unicode_str))
79
79
 
80
80
 
 
81
def get_cached_utf8(utf8_str):
 
82
    """Return a cached version of the utf-8 string.
 
83
 
 
84
    Get a cached version of this string (similar to intern()).
 
85
    At present, this will be decoded to ensure it is a utf-8 string. In the
 
86
    future this might change to simply caching the string.
 
87
    """
 
88
    return encode(decode(utf8_str))
 
89
 
 
90
 
81
91
def clear_encoding_cache():
82
92
    """Clear the encoding and decoding caches"""
83
93
    _unicode_to_utf8_map.clear()