+++ /dev/null
-/*
- * The UniCode Library -- Debugging Support Functions
- *
- * (c) 1997 Martin Mares <mj@ucw.cz>
- *
- * This software may be freely distributed and used according to the terms
- * of the GNU Lesser General Public License.
- */
-
-#include "lib/lib.h"
-#include "charset/unicode.h"
-
-static byte *
-get_static_buffer(uns size)
-{
- static byte *static_debug_buffer;
- static uns static_debug_size;
-
- if (!static_debug_buffer)
- {
- if (size < 1024)
- size = 1024;
- static_debug_buffer = xmalloc(size);
- static_debug_size = size;
- }
- else if (static_debug_size < size)
- {
- size = (size+1023) & ~1023;
- static_debug_buffer = xrealloc(static_debug_buffer, size);
- static_debug_size = size;
- }
- return static_debug_buffer;
-}
-
-byte *
-static_ucs2_to_utf8(word *w)
-{
- byte *buf = get_static_buffer(Ustrlen(w) * 3 + 1);
-
- ucs2_to_utf8(buf, w);
- return buf;
-}
+++ /dev/null
-/*
- * The UniCode Library -- String Length
- *
- * (c) 1997--2003 Martin Mares <mj@ucw.cz>
- * (c) 2003 Robert Spalek <robert@ucw.cz>
- *
- * This software may be freely distributed and used according to the terms
- * of the GNU Lesser General Public License.
- */
-
-#include "lib/lib.h"
-#include "charset/unicode.h"
-
-uns
-Ustrlen(word *w)
-{
- word *z = w;
-
- while (*z)
- z++;
- return z - w;
-}
-
-uns
-utf8_strlen(byte *str)
-{
- uns len = 0;
- while (*str)
- {
- UTF8_SKIP(str);
- len++;
- }
- return len;
-}
-
-uns
-utf8_strnlen(byte *str, uns n)
-{
- uns len = 0;
- byte *end = str + n;
- while (str < end)
- {
- UTF8_SKIP(str);
- len++;
- }
- return len;
-}
+++ /dev/null
-/*
- * The UniCode Library -- UTF-8 Functions
- *
- * (c) 1997 Martin Mares <mj@ucw.cz>
- *
- * This software may be freely distributed and used according to the terms
- * of the GNU Lesser General Public License.
- */
-
-#include "lib/lib.h"
-#include "charset/unicode.h"
-
-uns
-ucs2_to_utf8(byte *d, word *s)
-{
- byte *d0 = d;
-
- while (*s)
- {
- uns u = *s++;
- PUT_UTF8(d,u);
- }
- *d = 0;
- return d - d0;
-}
-
-uns
-utf8_to_ucs2(word *d, byte *s)
-{
- word *d0 = d;
-
- while (*s)
- if (IS_UTF8(*s))
- {
- uns u;
- GET_UTF8_CHAR(s,u);
- *d++ = u;
- }
- else if (*s >= 0x80)
- *d++ = UNI_REPLACEMENT;
- else
- *d++ = *s++;
- *d = 0;
- return d - d0;
-}