1 | /* FriBidi |
2 | * fribidi-char-sets-iso8859-8.c - ISO8859-8 character set conversion routines |
3 | * |
4 | * Authors: |
5 | * Behdad Esfahbod, 2001, 2002, 2004 |
6 | * Dov Grobgeld, 1999, 2000 |
7 | * |
8 | * Copyright (C) 2004 Sharif FarsiWeb, Inc |
9 | * Copyright (C) 2001,2002 Behdad Esfahbod |
10 | * Copyright (C) 1999,2000 Dov Grobgeld |
11 | * |
12 | * This library is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Lesser General Public |
14 | * License as published by the Free Software Foundation; either |
15 | * version 2.1 of the License, or (at your option) any later version. |
16 | * |
17 | * This library is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Lesser General Public License for more details. |
21 | * |
22 | * You should have received a copy of the GNU Lesser General Public License |
23 | * along with this library, in a file named COPYING; if not, write to the |
24 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 | * Boston, MA 02110-1301, USA |
26 | * |
27 | * For licensing issues, contact <fribidi.license@gmail.com>. |
28 | */ |
29 | |
30 | #include <common.h> |
31 | |
32 | #include <fribidi-char-sets-iso8859-8.h> |
33 | |
34 | #include <fribidi-unicode.h> |
35 | |
36 | /* The following are proposed extensions to ISO8859-8. */ |
37 | #define ISO_8859_8_LRM 0xFD |
38 | #define ISO_8859_8_RLM 0xFE |
39 | #define ISO_8859_8_LRE 0xFB |
40 | #define ISO_8859_8_RLE 0xFC |
41 | #define ISO_8859_8_PDF 0xDD |
42 | #define ISO_8859_8_LRO 0xDB |
43 | #define ISO_8859_8_RLO 0xDC |
44 | #define ISO_ALEF 0xE0 |
45 | #define ISO_TAV 0xFA |
46 | |
47 | #define UNI_ALEF 0x05D0 |
48 | #define UNI_TAV 0x05EA |
49 | |
50 | FriBidiChar |
51 | fribidi_iso8859_8_to_unicode_c ( |
52 | /* input */ |
53 | char sch |
54 | ) |
55 | { |
56 | register unsigned char ch = (unsigned char) sch; |
57 | if (ch < ISO_8859_8_LRO) |
58 | return ch; |
59 | else if (ch >= ISO_ALEF && ch <= ISO_TAV) |
60 | return ch - ISO_ALEF + UNI_ALEF; |
61 | switch (ch) |
62 | { |
63 | case ISO_8859_8_RLM: |
64 | return FRIBIDI_CHAR_RLM; |
65 | case ISO_8859_8_LRM: |
66 | return FRIBIDI_CHAR_LRM; |
67 | case ISO_8859_8_RLO: |
68 | return FRIBIDI_CHAR_RLO; |
69 | case ISO_8859_8_LRO: |
70 | return FRIBIDI_CHAR_LRO; |
71 | case ISO_8859_8_RLE: |
72 | return FRIBIDI_CHAR_RLE; |
73 | case ISO_8859_8_LRE: |
74 | return FRIBIDI_CHAR_LRE; |
75 | case ISO_8859_8_PDF: |
76 | return FRIBIDI_CHAR_PDF; |
77 | default: |
78 | return '?'; |
79 | } |
80 | } |
81 | |
82 | char |
83 | fribidi_unicode_to_iso8859_8_c ( |
84 | /* input */ |
85 | FriBidiChar uch |
86 | ) |
87 | { |
88 | if (uch < 128) |
89 | return (char) uch; |
90 | if (uch >= UNI_ALEF && uch <= UNI_TAV) |
91 | return (char) (uch - UNI_ALEF + ISO_ALEF); |
92 | switch (uch) |
93 | { |
94 | case FRIBIDI_CHAR_RLM: |
95 | return (char) ISO_8859_8_RLM; |
96 | case FRIBIDI_CHAR_LRM: |
97 | return (char) ISO_8859_8_LRM; |
98 | case FRIBIDI_CHAR_RLO: |
99 | return (char) ISO_8859_8_RLO; |
100 | case FRIBIDI_CHAR_LRO: |
101 | return (char) ISO_8859_8_LRO; |
102 | case FRIBIDI_CHAR_RLE: |
103 | return (char) ISO_8859_8_RLE; |
104 | case FRIBIDI_CHAR_LRE: |
105 | return (char) ISO_8859_8_LRE; |
106 | case FRIBIDI_CHAR_PDF: |
107 | return (char) ISO_8859_8_PDF; |
108 | } |
109 | return '?'; |
110 | } |
111 | |
112 | /* Editor directions: |
113 | * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent |
114 | */ |
115 | |