Commit | Line | Data |
---|---|---|
8d138742 CE |
1 | /* |
2 | ** Copyright 2000-2003 Double Precision, Inc. | |
3 | ** See COPYING for distribution information. | |
4 | ** | |
5 | ** $Id: iso8859_convert.c,v 1.2 2003/03/07 00:47:31 mrsam Exp $ | |
6 | */ | |
7 | ||
8 | #include "unicode_config.h" | |
9 | #include "unicode.h" | |
10 | #include <string.h> | |
11 | #include <stdlib.h> | |
12 | ||
13 | ||
14 | char *unicode_iso8859_convert(const char *str, int *err, | |
15 | const char *table) | |
16 | { | |
17 | char *p=strdup(str), *q; /* Lazy bum */ | |
18 | ||
19 | if (err) *err= -1; | |
20 | ||
21 | if (!p) return (0); | |
22 | ||
23 | for (q=p; *q; q++) | |
24 | { | |
25 | char c= table[(int)(unsigned char)*q]; | |
26 | ||
27 | if (!c) | |
28 | { | |
29 | if (err) | |
30 | { | |
31 | *err= q-p; | |
32 | free(p); | |
33 | return (0); | |
34 | } | |
35 | } | |
36 | else | |
37 | *q=c; | |
38 | } | |
39 | return (p); | |
40 | } |