SILC Runtime Toolkit 1.2 Beta 1
[runtime.git] / lib / silcutil / silcutf8.h
index ba09b4e91f4f48dd2c8bf14001db6da6784f937e..47e951bcc0d9565a5c2ff493092b51ecdc6f62de 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2004 - 2005 Pekka Riikonen
+  Copyright (C) 2004 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 
 */
 
-/****h* silcutil/SILC UTF-8 Interface
+/****h* silcutil/UTF-8 Interface
  *
  * DESCRIPTION
  *
@@ -30,7 +30,7 @@
 #ifndef SILCUTF8_H
 #define SILCUTF8_H
 
-/****f* silcutil/SilcUTF8API/silc_utf8_encode
+/****f* silcutil/silc_utf8_encode
  *
  * SYNOPSIS
  *
@@ -51,7 +51,7 @@ SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len,
                            SilcStringEncoding bin_encoding,
                            unsigned char *utf8, SilcUInt32 utf8_size);
 
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_decode
+/****f* silcutil/silc_utf8_decode
  *
  * SYNOPSIS
  *
@@ -74,7 +74,52 @@ SilcUInt32 silc_utf8_decode(const unsigned char *utf8, SilcUInt32 utf8_len,
                            SilcStringEncoding bin_encoding,
                            unsigned char *bin, SilcUInt32 bin_size);
 
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_encoded_len
+/****f* silcutil/silc_utf8_c2w
+ *
+ * SYNOPSIS
+ *
+ *    SilcUInt32 silc_utf8_c2w(const unsigned char *utf8,
+ *                             SilcUInt32 utf8_len,
+ *                             SilcUInt16 *utf8_wide,
+ *                             SilcUInt32 utf8_wide_size);
+ *
+ * DESCRIPTION
+ *
+ *    Converts UTF-8 string into UTF-8 wide character string into the
+ *    `utf8_wide' buffer of size of `utf8_wide_size' in characters.  Returns
+ *    the length of the UTF-8 wide character string or 0 on error.  The
+ *    returned length is in characters and not in bytes.  The byte length
+ *    is twice the returned character length.
+ *
+ *    If there is extra space in `utf8_wide' this will NULL terminate the
+ *    string automatically.
+ *
+ ***/
+SilcUInt32 silc_utf8_c2w(const unsigned char *utf8, SilcUInt32 utf8_len,
+                        SilcUInt16 *utf8_wide, SilcUInt32 utf8_wide_size);
+
+/****f* silcutil/silc_utf8_w2c
+ *
+ * SYNOPSIS
+ *
+ *    SilcUInt32 silc_utf8_w2c(const SilcUInt16 *wide_str,
+ *                             SilcUInt32 wide_str_len,
+ *                             unsigned char *utf8, SilcUInt32 utf8_size);
+ *
+ * DESCRIPTION
+ *
+ *    Converts UTF-8 wide character string into UTF-8 binary string into the
+ *    `utf8' buffer of size of `utf8_size' in bytes.  Returns the length of
+ *    the encoded UTF-8 string in bytes or 0 on error.
+ *
+ *    If there is extra space in `utf8' this will NULL terminate the string
+ *    automatically.
+ *
+ ***/
+SilcUInt32 silc_utf8_w2c(const SilcUInt16 *wide_str, SilcUInt32 wide_str_len,
+                        unsigned char *utf8, SilcUInt32 utf8_size);
+
+/****f* silcutil/silc_utf8_encoded_len
  *
  * SYNOPSIS
  *
@@ -92,7 +137,7 @@ SilcUInt32 silc_utf8_decode(const unsigned char *utf8, SilcUInt32 utf8_len,
 SilcUInt32 silc_utf8_encoded_len(const unsigned char *bin, SilcUInt32 bin_len,
                                 SilcStringEncoding bin_encoding);
 
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_decoded_len
+/****f* silcutil/silc_utf8_decoded_len
  *
  * SYNOPSIS
  *
@@ -110,11 +155,11 @@ SilcUInt32 silc_utf8_encoded_len(const unsigned char *bin, SilcUInt32 bin_len,
 SilcUInt32 silc_utf8_decoded_len(const unsigned char *bin, SilcUInt32 bin_len,
                                 SilcStringEncoding bin_encoding);
 
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_valid
+/****f* silcutil/silc_utf8_valid
  *
  * SYNOPSIS
  *
- *    bool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
+ *    SilcBool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
  *
  * DESCRIPTION
  *
@@ -122,13 +167,13 @@ SilcUInt32 silc_utf8_decoded_len(const unsigned char *bin, SilcUInt32 bin_len,
  *    UTF-8 encoded string, FALSE if it is not UTF-8 encoded string.
  *
  ***/
-bool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
+SilcBool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
 
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_strcasecmp
+/****f* silcutil/silc_utf8_strcasecmp
  *
  * SYNOPSIS
  *
- *    bool silc_utf8_strcasecmp(const char *s1, const char *s2);
+ *    SilcBool silc_utf8_strcasecmp(const char *s1, const char *s2);
  *
  * DESCRIPTION
  *
@@ -141,14 +186,14 @@ bool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
  *    Unicode characters will be ignored when comparing.
  *
  ***/
-bool silc_utf8_strcasecmp(const char *s1, const char *s2);
+SilcBool silc_utf8_strcasecmp(const char *s1, const char *s2);
 
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_strncasecmp
+/****f* silcutil/silc_utf8_strncasecmp
  *
  * SYNOPSIS
  *
- *    bool silc_utf8_strcasecmp(const char *s1, const char *s2,
- *                              SilcUInt32 n);
+ *    SilcBool silc_utf8_strcasecmp(const char *s1, const char *s2,
+ *                                  SilcUInt32 n);
  *
  * DESCRIPTION
  *
@@ -161,6 +206,6 @@ bool silc_utf8_strcasecmp(const char *s1, const char *s2);
  *    Unicode characters will be ignored when comparing.
  *
  ***/
-bool silc_utf8_strncasecmp(const char *s1, const char *s2, SilcUInt32 n);
+SilcBool silc_utf8_strncasecmp(const char *s1, const char *s2, SilcUInt32 n);
 
 #endif /* SILCUTF8_H */