- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / include / inc_t1ps_ar2uni.php
blob2af67d839a655605d8a3a15685c3778a7b793f52
1 <?php
2 #====================================================================================================#
3 # ar2uni v0.1 (Arabic-win1256 encoder to Unicode) #
4 #====================================================================================================#
5 # Information: #
6 # This is PHP function for covert Arabic encoding string to #
7 # unicode that can use to show Arabic charactor in PDF Documents. #
8 # It Tested and worked with Multilanguage arial.ttf V2.98 #
9 # #
10 # Version History: #
11 # version 0.1 : First release. created on ( 22/01/2004) By Walid Fathalla #
12 # #
13 # Bug Report and Suggestion to: #
14 # Walid Fathalla #
15 # fathalla_w@hotmail.com #
16 # #
17 #====================================================================================================#
18 # Example: #
19 # include_once($root_path.'inc_ttf_ar2uni.php'); #
20 # ImageTTFText ($image, 8, 0, 3, 15, $white, "arial.ttf",ar2uni("$ArabicString")); #
21 #====================================================================================================#
22 # For Arabic Website: If you thing this module useful to you, please send to #
23 # me back to my email fathalla_w@hotmail.com. #
24 # #
25 #====================================================================================================#
27 #================================================// Arabic character maps//=============================================
29 $ar2unimap = array( // One bit character isolated form
30 ',' => 161, 'º' => 162, '¿' => 163, 'Á' => 164, 'Â' => 165, 'Ã' => 166, 'Ä' => 167,
31 'Å' => 168, 'Æ' => 169, 'Ç' => 170, 'È' => 171, 'É' => 172, 'Ê' => 174, 'Ë' => 176,
32 'Ì' => 177, 'Í' => 178, 'Î' => 179, 'Ï' => 180, 'Ð' => 182, 'Ñ' => 184, 'Ò' => 185,
33 'Ó' => 186, 'Ô' => 187, 'Õ' => 188, 'Ö' => 189, 'Ø' => 190, 'Ù' => 191, 'Ú' => 192,
34 'Û' => 193, 'Ü' => 194, 'Ý' => 195, 'Þ' => 196, 'ß' => 197, 'á' => 198, 'ã' => 199,
35 'ä' => 200, 'å' => 201, 'æ' => 202, 'ì' => 203, 'í' => 204);
37 $ar2unimap2 = array( // One bit character initial form
38 'Â' => 165, 'Ã' => 166, 'Ä' => 167, 'Å' => 168, 'Æ' => 205, 'Ç' => 170, 'È' => 206,
39 'Ê' => 207, 'Ë' => 208, 'Ì' => 209, 'Í' => 210, 'Î' => 211, 'Ï' => 180, 'Ð' => 182,
40 'Ñ' => 184, 'Ò' => 185, 'Ó' => 212, 'Ô' => 213, 'Õ' => 214, 'Ö' => 215, 'Ø' => 190,
41 'Ù' => 191, 'Ú' => 216, 'Û' => 217, 'Ý' => 218, 'Þ' => 219, 'ß' => 220, 'á' => 221,
42 'ã' => 222, 'ä' => 223, 'å' => 224, 'æ' => 202, 'í' => 225);
44 $ar2unimap3 = array( // One bit character medial form
45 'Æ' => 205, 'È' => 206, 'Ê' => 207, 'Ë' => 208, 'Ì' => 209, 'Í' => 210, 'Î' => 211,
46 'Ó' => 212, 'Ô' => 213, 'Õ' => 214, 'Ö' => 215, 'Ø' => 190, 'Ù' => 191, 'Ú' => 226,
47 'Û' => 227, 'Ý' => 228, 'Þ' => 229, 'ß' => 220, 'á' => 221, 'ã' => 222, 'ä' => 223,
48 'å' => 230, 'í' => 225);
50 $ar2unimap4 = array( // One bit character final form
51 'Â' => 231, 'Ã' => 232, 'Ä' => 167, 'Å' => 233, 'Æ' => 234, 'Ç' => 235, 'È' => 171,
52 'É' => 236, 'Ê' => 174, 'Ë' => 176, 'Ì' => 237, 'Í' => 238, 'Î' => 239, 'Ï' => 180,
53 'Ð' => 182, 'Ñ' => 184, 'Ò' => 185, 'Ó' => 186, 'Ô' => 187, 'Õ' => 188, 'Ö' => 189,
54 'Ø' => 190, 'Ù' => 191, 'Ú' => 240, 'Û' => 241, 'Ý' => 195, 'Þ' => 196, 'ß' => 197,
55 'á' => 198, 'ã' => 199, 'ä' => 200, 'å' => 242, 'æ' => 202, 'ì' => 243, 'í' => 244);
57 $ar2unimap5 = array( // Two bit character isolated & initial form
58 'áÂ' => 245,
59 'áÃ' => 246,
60 'áÅ' => 247,
61 'áÇ' => 248);
63 $ar2unimap6 = array( // Two bit character final form
64 'áÂ' => 249,
65 'áÃ' => 250,
66 'áÅ' => 251,
67 'áÇ' => 252);
71 #================================================// end of character maps//=============================================
73 function ar2uni($sti){
74 global $ar2unimap,$ar2unimap2,$ar2unimap3,$ar2unimap4,$ar2unimap5,$ar2unimap6;
76 # START: (FIX) By Tarek Alwerfally on 16/12/2005
77 if( ($sti[0]>='A' && $sti[0]<='Z') || ($sti[0]>='a' && $sti[0]<='z') ) return( $sti );
78 # END: By Tarek Alwerfally on 16/12/2005
81 $sti .= " ";
82 $temp = $sti;
83 $sti = strrev($temp);
84 $sti .= " ";
85 $sto='';
86 $len=strlen($sti);
89 for ($i=1; $i < $len-1; $i++){
90 #=========================// for one bit character have 4 forms//================
91 if($ar2unimap3[$sti{$i}]){
93 if($sti{$i-1}==" " and $sti{$i+1}==" "){
94 $sto .=chr($ar2unimap[$sti{$i}]);
96 }elseif($sti{$i-1}==" "){
98 if($ar2unimap3[$sti{$i+1}]){
99 $sto .=chr($ar2unimap4[$sti{$i}]);
100 }else{
101 $sto .=chr($ar2unimap[$sti{$i}]);
104 }elseif($sti{$i+1}==" "){
105 $sto .=chr($ar2unimap2[$sti{$i}]);
106 }else{
108 if($ar2unimap3[$sti{$i+1}]){
109 $sto .=chr($ar2unimap3[$sti{$i}]);
110 }else{
111 $sto .=chr($ar2unimap2[$sti{$i}]);
114 #=========================// for one bit character have 3 forms//================
115 }elseif($ar2unimap2[$sti{$i}]){
117 if($sti{$i-1}==" " and $sti{$i+1}==" "){
118 $sto .=chr($ar2unimap[$sti{$i}]);
120 }elseif($sti{$i-1}==" "){
122 if($ar2unimap3[$sti{$i+1}]){
124 if($sti{$i}=="Â" and $sti{$i+1}=="á"){// to check lam alef Two bit character
125 if($ar2unimap3[$sti{$i+2}]){
126 $sto .=chr($ar2unimap6["áÂ"]);
127 }else{
128 $sto .=chr($ar2unimap5["áÂ"]);
130 $i++;
131 }elseif($sti{$i}=="Ã" and $sti{$i+1}=="á"){
132 if($ar2unimap3[$sti{$i+2}]){
133 $sto .=chr($ar2unimap6["áÃ"]);
134 }else{
135 $sto .=chr($ar2unimap5["áÃ"]);
137 $i++;
138 }elseif($sti{$i}=="Å" and $sti{$i+1}=="á"){
139 if($ar2unimap3[$sti{$i+2}]){
140 $sto .=chr($ar2unimap6["áÅ"]);
141 }else{
142 $sto .=chr($ar2unimap5["áÅ"]);
144 $i++;
145 }elseif($sti{$i}=="Ç" and $sti{$i+1}=="á"){
146 if($ar2unimap3[$sti{$i+2}]){
147 $sto .=chr($ar2unimap6["áÇ"]);
148 }else{
149 $sto .=chr($ar2unimap5["áÇ"]);
151 $i++;
152 }else{
153 $sto .=chr($ar2unimap4[$sti{$i}]);
156 }else{
157 $sto .=chr($ar2unimap[$sti{$i}]);
160 }elseif($sti{$i+1}==" "){
161 $sto .=chr($ar2unimap[$sti{$i}]);
162 }else{
164 if($ar2unimap3[$sti{$i+1}]){
166 if($sti{$i}=="Â" and $sti{$i+1}=="á"){// to check lam alef Two bit character
167 if($ar2unimap3[$sti{$i+2}]){
168 $sto .=chr($ar2unimap6["áÂ"]);
169 }else{
170 $sto .=chr($ar2unimap5["áÂ"]);
172 $i++;
173 }elseif($sti{$i}=="Ã" and $sti{$i+1}=="á"){
174 if($ar2unimap3[$sti{$i+2}]){
175 $sto .=chr($ar2unimap6["áÃ"]);
176 }else{
177 $sto .=chr($ar2unimap5["áÃ"]);
179 $i++;
180 }elseif($sti{$i}=="Å" and $sti{$i+1}=="á"){
181 if($ar2unimap3[$sti{$i+2}]){
182 $sto .=chr($ar2unimap6["áÅ"]);
183 }else{
184 $sto .=chr($ar2unimap5["áÅ"]);
186 $i++;
187 }elseif($sti{$i}=="Ç" and $sti{$i+1}=="á"){
188 if($ar2unimap3[$sti{$i+2}]){
189 $sto .=chr($ar2unimap6["áÇ"]);
190 }else{
191 $sto .=chr($ar2unimap5["áÇ"]);
193 $i++;
194 }else{
195 $sto .=chr($ar2unimap4[$sti{$i}]);
198 }else{
199 $sto .=chr($ar2unimap[$sti{$i}]);
202 #=========================// for one bit character have 2forms//================
203 }elseif($ar2unimap4[$sti{$i}]){
205 if($sti{$i-1}==" " and $sti{$i+1}==" "){
206 $sto .=chr($ar2unimap[$sti{$i}]);
208 }elseif($sti{$i-1}==" "){
210 if($ar2unimap3[$sti{$i+1}]){
211 $sto .=chr($ar2unimap4[$sti{$i}]);
212 }else{
213 $sto .=chr($ar2unimap[$sti{$i}]);
216 }elseif($sti{$i+1}==" "){
217 $sto .=chr($ar2unimap[$sti{$i}]);
218 }else{
220 if($ar2unimap3[$sti{$i+1}]){
221 $sto .=chr($ar2unimap4[$sti{$i}]);
222 }else{
223 $sto .=chr($ar2unimap[$sti{$i}]);
226 #=========================// for one bit character have 1 form//================
227 }elseif($ar2unimap[$sti{$i}]){
228 $sto .=chr($ar2unimap[$sti{$i}]);
229 }else{
230 $sto .= $sti{$i};
233 return $sto;