* Copyright 2000 Red Hat, Inc.
*
* The Gnome Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License as
+ * modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-#ifndef __GUNICODE_H__
-#define __GUNICODE_H__
+#ifndef __G_UNICODE_H__
+#define __G_UNICODE_H__
-#include <stdlib.h> /* For size_t */
+#include <stddef.h> /* For size_t */
+#include <gtypes.h>
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+G_BEGIN_DECLS
typedef guint32 gunichar;
typedef guint16 gunichar2;
/* These are all analogs of the <ctype.h> functions.
*/
-gboolean g_unichar_isalnum (gunichar c);
-gboolean g_unichar_isalpha (gunichar c);
-gboolean g_unichar_iscntrl (gunichar c);
-gboolean g_unicphar_isdigit (gunichar c);
-gboolean g_unichar_isgraph (gunichar c);
-gboolean g_unichar_islower (gunichar c);
-gboolean g_unichar_isprint (gunichar c);
-gboolean g_unichar_ispunct (gunichar c);
-gboolean g_unichar_isspace (gunichar c);
-gboolean g_unichar_isupper (gunichar c);
-gboolean g_unichar_isxdigit (gunichar c);
-gboolean g_unichar_istitle (gunichar c);
-gboolean g_unichar_isdefined (gunichar c);
-gboolean g_unichar_iswide (gunichar c);
+gboolean g_unichar_isalnum (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isalpha (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_iscntrl (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isdigit (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isgraph (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_islower (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isprint (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_ispunct (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isspace (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isupper (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isxdigit (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_istitle (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_isdefined (gunichar c) G_GNUC_CONST;
+gboolean g_unichar_iswide (gunichar c) G_GNUC_CONST;
/* More <ctype.h> functions. These convert between the three cases.
* See the Unicode book to understand title case. */
-gunichar g_unichar_toupper (gunichar c);
-gunichar g_unichar_tolower (gunichar c);
-gunichar g_unichar_totitle (gunichar c);
+gunichar g_unichar_toupper (gunichar c) G_GNUC_CONST;
+gunichar g_unichar_tolower (gunichar c) G_GNUC_CONST;
+gunichar g_unichar_totitle (gunichar c) G_GNUC_CONST;
/* If C is a digit (according to `g_unichar_isdigit'), then return its
numeric value. Otherwise return -1. */
-gint g_unichar_digit_value (gunichar c);
+gint g_unichar_digit_value (gunichar c) G_GNUC_CONST;
-gint g_unichar_xdigit_value (gunichar c);
+gint g_unichar_xdigit_value (gunichar c) G_GNUC_CONST;
/* Return the Unicode character type of a given character. */
-GUnicodeType g_unichar_type (gunichar c);
+GUnicodeType g_unichar_type (gunichar c) G_GNUC_CONST;
gunichar *g_unicode_canonical_decomposition (gunichar ch,
size_t *result_len);
-/* Array of skip-bytes-per-initial character
+/* Array of skip-bytes-per-initial character.
+ * We prefix variable declarations so they can
+ * properly get exported in windows dlls.
*/
-extern char g_utf8_skip[256];
+#ifndef GLIB_VAR
+# ifdef G_OS_WIN32
+# ifdef GLIB_COMPILATION
+# define GLIB_VAR __declspec(dllexport)
+# else /* !GLIB_COMPILATION */
+# define GLIB_VAR extern __declspec(dllimport)
+# endif /* !GLIB_COMPILATION */
+# else /* !G_OS_WIN32 */
+# define GLIB_VAR extern
+# endif /* !G_OS_WIN32 */
+#endif /* !GLIB_VAR */
+
+GLIB_VAR char g_utf8_skip[256];
#define g_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(guchar *)(p)])
const gchar *pos);
gchar * g_utf8_prev_char (const gchar *p);
gchar * g_utf8_find_next_char (const gchar *p,
- const gchar *bound);
+ const gchar *end);
gchar * g_utf8_find_prev_char (const gchar *str,
const gchar *p);
functions are equivalants to strchr and strrchr */
gchar *g_utf8_strchr (const gchar *p,
- gunichar ch);
+ gunichar c);
gchar *g_utf8_strrchr (const gchar *p,
- gunichar ch);
+ gunichar c);
gunichar2 *g_utf8_to_utf16 (const gchar *str,
gint len);
gint g_unichar_to_utf8 (gunichar c,
char *outbuf);
-#ifdef __cplusplus
-}
-#endif
+/* Validate a UTF8 string, return TRUE if valid, put pointer to
+ * first invalid char in **end
+ */
+
+gboolean g_utf8_validate (const gchar *str,
+ gint len,
+ const gchar **end);
+
+G_END_DECLS
-#endif /* GUNICODE_H */
+#endif /* __G_UNICODE_H__ */