From 748c31dc5de762942770b4cced8c1ea827d8e040 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 12 Apr 2011 10:36:37 +1000 Subject: lib/util/charset Add convert_string_error() This adds an interface that matches the source3/ convert string code. Andrew Bartlett Signed-off-by: Andrew Tridgell --- lib/util/charset/charset.h | 4 ++++ lib/util/charset/util_unistr.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index 9e2aa8f136..1078035592 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -174,6 +174,10 @@ bool convert_string(charset_t from, charset_t to, void const *src, size_t srclen, void *dest, size_t destlen, size_t *converted_size); +bool convert_string_error(charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen, + size_t *converted_size); ssize_t iconv_talloc(TALLOC_CTX *mem_ctx, smb_iconv_t cd, diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index 41549bff87..6737256a95 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -701,6 +701,27 @@ _PUBLIC_ bool convert_string(charset_t from, charset_t to, dest, destlen, converted_size); } +/** + * Convert string from one encoding to another, making error checking etc + * + * @param src pointer to source string (multibyte or singlebyte) + * @param srclen length of the source string in bytes + * @param dest pointer to destination string (multibyte or singlebyte) + * @param destlen maximal length allowed for string + * @param converted_size the number of bytes occupied in the destination + * + * @returns true on success, false on fail. + **/ +_PUBLIC_ bool convert_string_error(charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen, + size_t *converted_size) +{ + return convert_string_error_handle(get_iconv_handle(), from, to, + src, srclen, + dest, destlen, converted_size); +} + /** * Convert between character sets, allocating a new buffer using talloc for the result. * -- cgit