File: unicode2.c

package info (click to toggle)
cone 0.75-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 31,040 kB
  • ctags: 13,930
  • sloc: ansic: 90,648; cpp: 79,781; sh: 18,355; perl: 3,218; makefile: 1,611; yacc: 289; sed: 16
file content (54 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
** Copyright 2000-2003 Double Precision, Inc.
** See COPYING for distribution information.
**
** $Id: unicode2.c,v 1.3 2003/03/07 00:47:31 mrsam Exp $
*/

#include	"unicode_config.h"
#include	"unicode.h"
#include	<string.h>
#include	<ctype.h>
#include	<stdlib.h>

char *unicode_toutf8(const unicode_char *u)
{
	return (unicode_utf8_fromu(u, 0));
}

unicode_char *unicode_fromutf8(const char *c)
{
	return (unicode_utf8_tou(c, 0));
}

char *unicode_ctoutf8(const struct unicode_info *ui, const char *c,
		      int *err)
{
	unicode_char *uc= (*ui->c2u)(ui, c, err);
	char *p;

	if (!uc) return (0);

	p=unicode_utf8_fromu(uc, err);
	if (err && *err > 0)
		*err=0;

	free(uc);
	return (p);
}

char *unicode_cfromutf8(const struct unicode_info *ui, const char *c,
			int *err)
{
	unicode_char *uc;
	char *p;

	uc=unicode_utf8_tou(c, err);
	if (!uc) return (0);

	p=(*ui->u2c)(ui, uc, err);
	free(uc);
	if (err && *err > 0)
		*err=0;
	return (p);
}