update to 0.19.7
[platform/upstream/fribidi.git] / charset / fribidi-char-sets-iso8859-6.c
1 /* FriBidi
2  * fribidi-char-sets-iso8859-6.c - ISO8859-6 character set conversion routines
3  *
4  * $Id: fribidi-char-sets-iso8859-6.c,v 1.2 2004-05-03 22:05:19 behdad Exp $
5  * $Author: behdad $
6  * $Date: 2004-05-03 22:05:19 $
7  * $Revision: 1.2 $
8  * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/charset/fribidi-char-sets-iso8859-6.c,v $
9  *
10  * Authors:
11  *   Behdad Esfahbod, 2001, 2002, 2004
12  *   Dov Grobgeld, 1999, 2000
13  *
14  * Copyright (C) 2004 Sharif FarsiWeb, Inc
15  * Copyright (C) 2001,2002 Behdad Esfahbod
16  * Copyright (C) 1999,2000 Dov Grobgeld
17  * 
18  * This library is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU Lesser General Public
20  * License as published by the Free Software Foundation; either
21  * version 2.1 of the License, or (at your option) any later version.
22  * 
23  * This library is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26  * Lesser General Public License for more details.
27  * 
28  * You should have received a copy of the GNU Lesser General Public License
29  * along with this library, in a file named COPYING; if not, write to the
30  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
31  * Boston, MA 02110-1301, USA
32  * 
33  * For licensing issues, contact <license@farsiweb.info>.
34  */
35
36 #include <common.h>
37
38 #include <fribidi-char-sets-iso8859-6.h>
39
40 #define ISO_HAMZA               0xc1
41 #define ISO_SUKUN               0xf2
42
43 #define UNI_HAMZA               0x0621
44 #define UNI_SUKUN               0x0652
45
46 FriBidiChar
47 fribidi_iso8859_6_to_unicode_c (
48   /* input */
49   char sch
50 )
51 {
52   register unsigned char ch = (unsigned char) sch;
53   if (ch >= ISO_HAMZA && ch <= ISO_SUKUN)
54     return ch - ISO_HAMZA + UNI_HAMZA;
55   else
56     return ch;
57 }
58
59 char
60 fribidi_unicode_to_iso8859_6_c (
61   /* input */
62   FriBidiChar uch
63 )
64 {
65   if (uch >= UNI_HAMZA && uch <= UNI_SUKUN)
66     return (char) (uch - UNI_HAMZA + ISO_HAMZA);
67   else if (uch < 256)
68     return (char) uch;
69   else if (uch == 0x060c)
70     return (char) 0xac;
71   else if (uch == 0x061b)
72     return (char) 0xbb;
73   else if (uch == 0x061f)
74     return (char) 0xbf;
75   else
76     return '?';
77 }
78
79 /* Editor directions:
80  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
81  */