summaryrefslogtreecommitdiff
path: root/jni/iconv/extras/iconv_string.h
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/iconv/extras/iconv_string.h
Fresh start
Diffstat (limited to 'jni/iconv/extras/iconv_string.h')
-rw-r--r--jni/iconv/extras/iconv_string.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/jni/iconv/extras/iconv_string.h b/jni/iconv/extras/iconv_string.h
new file mode 100644
index 0000000..faab8c6
--- /dev/null
+++ b/jni/iconv/extras/iconv_string.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 1999-2001 Bruno Haible.
+ This file is not part of the GNU LIBICONV Library.
+ This file is put into the public domain. */
+
+/*
+ * This C function converts an entire string from one encoding to another,
+ * using iconv. Easier to use than iconv() itself, and supports autodetect
+ * encodings on input.
+ *
+ * int iconv_string (const char* tocode, const char* fromcode,
+ * const char* start, const char* end,
+ * char** resultp, size_t* lengthp)
+ *
+ * Converts a memory region given in encoding FROMCODE to a new memory
+ * region in encoding TOCODE. FROMCODE and TOCODE are as for iconv_open(3),
+ * except that FROMCODE may be one of the values
+ * "autodetect_utf8" supports ISO-8859-1 and UTF-8
+ * "autodetect_jp" supports EUC-JP, ISO-2022-JP-2 and SHIFT_JIS
+ * "autodetect_kr" supports EUC-KR and ISO-2022-KR
+ * The input is in the memory region between start (inclusive) and end
+ * (exclusive). If resultp is not NULL, the output string is stored in
+ * *resultp; malloc/realloc is used to allocate the result.
+ *
+ * This function does not treat zero characters specially.
+ *
+ * Return value: 0 if successful, otherwise -1 and errno set. Particular
+ * errno values: EILSEQ and ENOMEM.
+ *
+ * Example:
+ * const char* s = ...;
+ * char* result = NULL;
+ * if (iconv_string("UCS-4-INTERNAL", "autodetect_utf8",
+ * s, s+strlen(s)+1, &result, NULL) < 0)
+ * perror("iconv_string");
+ *
+ */
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int iconv_string (const char* tocode, const char* fromcode, const char* start, const char* end, char** resultp, size_t* lengthp);
+
+#ifdef __cplusplus
+}
+#endif