lib/charcnv/util_unistr: add next_codepoint_ext() that accepts input charset.
authorMichael Adam <obnox@samba.org>
Sun, 31 Oct 2010 01:18:46 +0000 (02:18 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 3 Nov 2010 22:45:20 +0000 (22:45 +0000)
next_codepoint() takes as string in CH_UNIX encoding and returns the
unicode codepoint of the next (possibly multibyte) character of the
input string.

The new next_codepoint_ext() function adds the encoding of the input
string as a parameter. next_codepoint() now only calls next_codepoint_ext()
with CH_UNIX als src_charset argument.

lib/util/charset/charset.h
lib/util/charset/util_unistr.c

index 7960631484dcf771ccc4c1900c3fca2669d31463..283212dbff7f86ec0cdbef41998d85ab4ec09a7b 100644 (file)
@@ -168,6 +168,8 @@ ssize_t iconv_talloc(TALLOC_CTX *mem_ctx,
 
 extern struct smb_iconv_convenience *global_iconv_convenience;
 
+codepoint_t next_codepoint_ext(const char *str, charset_t src_charset,
+                              size_t *size);
 codepoint_t next_codepoint(const char *str, size_t *size);
 ssize_t push_codepoint(char *str, codepoint_t c);
 
index 520ce054680ed1b43cb14b312db23602da60fd58..79a9ffe3df9f1904398e72c24f717906b325c624 100644 (file)
@@ -992,6 +992,12 @@ _PUBLIC_ bool convert_string_talloc(TALLOC_CTX *ctx,
                                                                                         allow_badcharcnv);
 }
 
+_PUBLIC_ codepoint_t next_codepoint_ext(const char *str, charset_t src_charset,
+                                       size_t *size)
+{
+       return next_codepoint_convenience_ext(get_iconv_convenience(), str,
+                                             src_charset, size);
+}
 
 _PUBLIC_ codepoint_t next_codepoint(const char *str, size_t *size)
 {