From: Yehuda Sadeh Date: Wed, 16 Jul 2014 23:05:58 +0000 (-0700) Subject: utf8: export encode_utf8() and decode_utf8() X-Git-Tag: v0.80.5~5^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d027ff1b432a265ad49ddfeafab45093bcd03e6c;p=ceph.git utf8: export encode_utf8() and decode_utf8() Signed-off-by: Yehuda Sadeh (cherry picked from commit 49fc68cf8c3122c878ea9503c9c74d7046bc9c6f) --- diff --git a/src/common/utf8.c b/src/common/utf8.c index d8e085391981..5bf0a5be8508 100644 --- a/src/common/utf8.c +++ b/src/common/utf8.c @@ -35,7 +35,7 @@ static int high_bits_set(int c) * Assumes buf is of size MAX_UTF8_SZ * Returns -1 on failure; number of bytes in the encoded value otherwise. */ -static int encode_utf8(unsigned long u, unsigned char *buf) +int encode_utf8(unsigned long u, unsigned char *buf) { int i; unsigned long max_val[MAX_UTF8_SZ] = { @@ -74,7 +74,7 @@ static int encode_utf8(unsigned long u, unsigned char *buf) * Decode a UTF8 character from an array of bytes. Return character code. * Upon error, return INVALID_UTF8_CHAR. */ -static unsigned long decode_utf8(unsigned char *buf, int nbytes) +unsigned long decode_utf8(unsigned char *buf, int nbytes) { unsigned long code; int i, j; diff --git a/src/common/utf8.h b/src/common/utf8.h index a25fe21b5c16..28649effaec4 100644 --- a/src/common/utf8.h +++ b/src/common/utf8.h @@ -44,6 +44,18 @@ int check_for_control_characters(const char *buf, int len); */ int check_for_control_characters_cstr(const char *buf); +/* Encode a 31-bit UTF8 code point to 'buf'. + * Assumes buf is of size MAX_UTF8_SZ + * Returns -1 on failure; number of bytes in the encoded value otherwise. + */ +int encode_utf8(unsigned long u, unsigned char *buf); + +/* + * Decode a UTF8 character from an array of bytes. Return character code. + * Upon error, return INVALID_UTF8_CHAR. + */ +unsigned long decode_utf8(unsigned char *buf, int nbytes); + #ifdef __cplusplus } #endif