utf8.c 2.13 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6 7
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

25
/**@CFILE utf8.c
Pekka Pessi's avatar
Pekka Pessi committed
26 27 28 29 30 31 32 33 34 35
 *
 * utf8 string handling.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 *
 * @date Created: Tue Apr 21 15:32:02 1998 pessi
 */

#include "config.h"

36
#include <sofia-sip/utf8.h>
Pekka Pessi's avatar
Pekka Pessi committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
#include "utf8internal.h"

#ifndef _WIN32
#include <assert.h>
#endif

/** Width of an UTF8 character cell (1, 2 or 4 bytes) */
size_t utf8_width(const utf8 *s)
{
  size_t w8 = 0, w16 = 0, w32 = 0;
  size_t errors = 0;		/* errors */

  UTF8_ANALYZE(s, w8, w8, w16, w32, errors);

  if (errors)
    return 0;

  return w32 ? 4 : (w16 ? 2 : 1);
}

/** Convert UTF8 string @a s to ISO-Latin-1 string @a dst. */
size_t ucs18decode(char *dst, size_t dst_size, const utf8 *s)
{
#ifndef _WIN32
  assert(!"implemented");
#endif
  return 0;
}

/** Convert ISO-Latin-1 string @a s to UTF8 string in @a dst. */
size_t ucs1encode(utf8 *dst, const ucs1 *s, size_t n, const char quote[128])
{
#ifndef _WIN32
  assert(!"implemented");
#endif
  return 0;
}

/** Calculate number of characters in UTF8 string @a s. */
size_t ucs1declen(const utf8 *s)
{
#ifndef _WIN32
  assert(!"implemented");
#endif
  return 0;
}

/** Calculate length of UTF8 encoding of string @a s. */
size_t ucs1enclen(const ucs1 *s, size_t n, const char quote[128])
{
#ifndef _WIN32
  assert(!"implemented");
#endif
  return 0;
}