summaryrefslogtreecommitdiff
path: root/protocols/SkypeClassic/src/utf8.h
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-10-29 08:47:48 +0000
committerRobert Pösel <robyer@seznam.cz>2013-10-29 08:47:48 +0000
commit50421b7809c47bd95c59b4a5627e2f89c8bccfa5 (patch)
tree323784b1c0bb7c86e5df509aab310fa1404680ef /protocols/SkypeClassic/src/utf8.h
parent8604516498f9135ac1c4379488228d84e69a89ab (diff)
SkypeClassic: Folders structure and project cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@6668 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeClassic/src/utf8.h')
-rw-r--r--protocols/SkypeClassic/src/utf8.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/protocols/SkypeClassic/src/utf8.h b/protocols/SkypeClassic/src/utf8.h
new file mode 100644
index 0000000000..70c533deca
--- /dev/null
+++ b/protocols/SkypeClassic/src/utf8.h
@@ -0,0 +1,47 @@
+/*
+ * Convert a string between UTF-8 and the locale's charset.
+ * Invalid bytes are replaced by '#', and characters that are
+ * not available in the target encoding are replaced by '?'.
+ *
+ * If the locale's charset is not set explicitly then it is
+ * obtained using nl_langinfo(CODESET), where available, the
+ * environment variable CHARSET, or assumed to be US-ASCII.
+ *
+ * Return value of conversion functions:
+ *
+ * -1 : memory allocation failed
+ * 0 : data was converted exactly
+ * 1 : valid data was converted approximately (using '?')
+ * 2 : input was invalid (but still converted, using '#')
+ * 3 : unknown encoding (but still converted, using '?')
+ */
+
+#ifndef __UTF8_H
+#define __UTF8_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void convert_set_charset(const char *charset);
+
+int utf8_encode(const char *from, char **to);
+int utf8_decode(const char *from, char **to);
+wchar_t *make_unicode_string(const unsigned char *utf8);
+unsigned char *make_utf8_string(const wchar_t *unicode);
+#ifdef _UNICODE
+#define make_tchar_string make_unicode_string
+// Helpers for strings that only can contain 7bit chars to not make unneccessary memory allocation
+#define make_nonutf_tchar_string(x) make_tchar_string(x)
+#define free_nonutf_tchar_string(x) if(x) free(x);
+#else
+char *make_tchar_string(const unsigned char *utf8);
+#define make_nonutf_tchar_string(x) (char*)x
+#define free_nonutf_tchar_string(x)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UTF8_H */