File: iso8859_convert.c

package info (click to toggle)
courier-authlib 0.63.0-6
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 17,720 kB
  • sloc: ansic: 60,549; sh: 10,525; perl: 3,503; makefile: 1,042; cpp: 284
file content (40 lines) | stat: -rw-r--r-- 605 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
/*
** Copyright 2000-2003 Double Precision, Inc.
** See COPYING for distribution information.
**
** $Id: iso8859_convert.c,v 1.2 2003/03/07 00:47:31 mrsam Exp $
*/

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


char *unicode_iso8859_convert(const char *str, int *err,
					const char *table)
{
char *p=strdup(str), *q;	/* Lazy bum */

	if (err)	*err= -1;

	if (!p)	return (0);

	for (q=p; *q; q++)
	{
	char c= table[(int)(unsigned char)*q];

		if (!c)
		{
			if (err)
			{
				*err= q-p;
				free(p);
				return (0);
			}
		}
		else
			*q=c;
	}
	return (p);
}