Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Preparation

Public general use code classes and xml files that we've compiled and used over the years:

Koran Reference Network Windows Form support functions: Business model

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Xml.Linq;
   6:  using System.Collections;
   7:  using System.Text;
   8:  using System.Text.RegularExpressions;
   9:  using System.Data;
  10:  using System.Data.Entity.Validation;
  11:  using System.Globalization;
  12:  using System.Drawing;
  13:  using System.Xml;
  14:  using System.Configuration;
  15:  using Ia.Islamic.Cl.Model;
  16:   
  17:  namespace Ia.Islamic.Koran.Wfa.Model.Business
  18:  {
  19:      ////////////////////////////////////////////////////////////////////////////
  20:   
  21:      /// <summary publish="true">
  22:      /// Koran Reference Network Windows Form support functions: Business model
  23:      /// </summary>
  24:      /// <value>
  25:      /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
  26:      /// </value>
  27:      /// <remarks> 
  28:      /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  29:      ///
  30:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  31:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  32:      ///
  33:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  34:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  35:      /// 
  36:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  37:      /// 
  38:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  39:      /// </remarks> 
  40:      public class Preparation
  41:      {
  42:          private static int count = 0;
  43:          private static Hashtable fix_ht = new Hashtable(1000);
  44:   
  45:          ////////////////////////////////////////////////////////////////////////////
  46:   
  47:          /// <summary>
  48:          ///
  49:          /// </summary>
  50:          public Preparation() 
  51:          {
  52:          }
  53:   
  54:          ////////////////////////////////////////////////////////////////////////////
  55:   
  56:          /// <summary>
  57:          ///
  58:          /// </summary>
  59:          public static void ProcessOthmaniIntermediateText()
  60:          {
  61:              string s;
  62:              StringBuilder sb;
  63:              ArrayList al, word_al;
  64:              MatchCollection mc;
  65:   
  66:              sb = new StringBuilder(100000000);
  67:              al = new ArrayList(100);
  68:              word_al = new ArrayList(300000);
  69:   
  70:              s = Ia.Cl.Model.File.Read("قرءان من عثماني.txt", System.Text.Encoding.GetEncoding(1252));
  71:   
  72:              s = s.Replace("dir=LTR", "");
  73:              s = s.Replace("dir=RTL", "");
  74:              s = s.Replace(@"style='font-size:14.0pt;font-family:", "");
  75:              s = Regex.Replace(s, @"style=\'font-size:\s+?14.0pt;font-family:", @"", RegexOptions.Singleline);
  76:              s = s.Replace(@"class=MsoNormal", "");
  77:              s = s.Replace(@"style='text-align:justify'", "");
  78:              s = s.Replace(@"style='text-align:center'", "");
  79:              s = s.Replace(@"style='font-size:14.0pt", "");
  80:              s = s.Replace(@"style='font-size: 14.0pt", "");
  81:              s = s.Replace(@"align=center", "");
  82:              s = s.Replace(@"lang=AR-SA", "");
  83:              s = s.Replace(@"<span> </span>", @" ");
  84:              s = s.Replace(@"<span></span>", @"");
  85:              s = Regex.Replace(s, @"<span\s+?></span>", @"", RegexOptions.Singleline);
  86:              s = Regex.Replace(s, @"<span\s+?> </span>", @"[0 ]", RegexOptions.Singleline);
  87:              s = Regex.Replace(s, @"<span\s+?'></span>", @"", RegexOptions.Singleline);
  88:              s = Regex.Replace(s, @"<span\s+?'> </span>", @"[0 ]", RegexOptions.Singleline);
  89:              s = Regex.Replace(s, @"<span\s+?HQPB\d'></span>", @"", RegexOptions.Singleline);
  90:              s = Regex.Replace(s, @"<p>.+?</p>", @" ", RegexOptions.Singleline);
  91:              s = Regex.Replace(s, @"<span\s+?HQPB(\d)'>(.+?)</span>", @"[$1$2]", RegexOptions.Singleline);
  92:              s = Regex.Replace(s, @"<span\s+?>\s+?</span>", @"", RegexOptions.Singleline);
  93:   
  94:              s = s.Replace("&quot;", @"""");
  95:              s = s.Replace("&gt;", ">");
  96:              s = s.Replace("&lt;", "<");
  97:              s = s.Replace("&amp;", "&");
  98:              s = s.Replace("&nbsp;", " ");
  99:   
 100:              s = s.Replace("</u>", " ");
 101:              s = s.Replace("</b>", " ");
 102:              s = s.Replace("</p>", " ");
 103:              s = s.Replace("<u>", " ");
 104:              s = s.Replace("<b>", " ");
 105:              s = s.Replace("<p>", " ");
 106:   
 107:              s = s.Replace("&#128;", ((char)128).ToString());
 108:              s = s.Replace("&#130;", ((char)130).ToString());
 109:              s = s.Replace("&#131;", ((char)131).ToString());
 110:              s = s.Replace("&#132;", ((char)132).ToString());
 111:              s = s.Replace("&#133;", ((char)133).ToString());
 112:              s = s.Replace("&#134;", ((char)134).ToString());
 113:              s = s.Replace("&#135;", ((char)135).ToString());
 114:              s = s.Replace("&#136;", ((char)136).ToString());
 115:              s = s.Replace("&#137;", ((char)137).ToString());
 116:              s = s.Replace("&#138;", ((char)138).ToString());
 117:              s = s.Replace("&#139;", ((char)139).ToString());
 118:              s = s.Replace("&#140;", ((char)140).ToString());
 119:              s = s.Replace("&#142;", ((char)142).ToString());
 120:              s = s.Replace("&#145;", ((char)145).ToString());
 121:              s = s.Replace("&#146;", ((char)146).ToString());
 122:              s = s.Replace("&#147;", ((char)147).ToString());
 123:              s = s.Replace("&#148;", ((char)148).ToString());
 124:              s = s.Replace("&#149;", ((char)149).ToString());
 125:              s = s.Replace("&#150;", ((char)150).ToString());
 126:              s = s.Replace("&#151;", ((char)151).ToString());
 127:              s = s.Replace("&#152;", ((char)152).ToString());
 128:              s = s.Replace("&#153;", ((char)153).ToString());
 129:              s = s.Replace("&#154;", ((char)154).ToString());
 130:              s = s.Replace("&#155;", ((char)155).ToString());
 131:              s = s.Replace("&#156;", ((char)156).ToString());
 132:              s = s.Replace("&#158;", ((char)158).ToString());
 133:              s = s.Replace("&#159;", ((char)159).ToString());
 134:   
 135:              s = Regex.Replace(s, @"&#\d{4};", @" ", RegexOptions.Singleline);
 136:   
 137:              // below: remove double spaces
 138:              s = Regex.Replace(s, @"\s+", " ");
 139:   
 140:              s = s.Replace("<p > <span '> : </span> <p ><span '> </span>", "");
 141:   
 142:              // below: char based bismillah, I will remove all
 143:              s = s.Replace(" <p ><span '> : </span> <p ><span '> </span> <p ><span ; font-family:HQPB3'>i</span>[3j][3k] <p ><span '> </span>", "[0 ]");
 144:              s = s.Replace("  <p ><span ; font-family:HQPB3'>i</span>[3j][3k] <p ><span '> </span>", "[0 ]");
 145:              s = s.Replace(" <p > <span '> : </span> <p ><span ; font-family:HQPB3'>i</span>[3j][3k] <p ><span '> </span>", "[0 ]");
 146:              s = s.Replace(" <p >", "");
 147:              s = Regex.Replace(s, @"<span ; font-family:HQPB\d'>.</span>", "");
 148:              s = s.Replace("<span '> </span>", "");
 149:              s = s.Replace("<span '> : </span>", "");
 150:              s = s.Replace(" </div> <span \"Times New Roman\",\"serif\"'><br clear=all style='page-break-before:auto'> </span> <div class=Section2 >[3j][3k]", "[0 ]");
 151:              s = s.Replace(" </div> <span \"Times New Roman\",\"serif\"'><br clear=all style='page-break-before:auto'> </span> <div class=Section3 >[3j][3k]", "[0 ]");
 152:              s = s.Replace(" </div> <span \"Times New Roman\",\"serif\"'><br clear=all style='page-break-before:always'> </span> <div class=Section4 >[3j][3k]", "[0 ]");
 153:              s = s.Replace("<span style='font-size:19.0pt'> </span>[3j][3k]", "[0 ]");
 154:              s = s.Replace("[3j][3k]", "[0 ]");
 155:   
 156:              mc = Regex.Matches(s, @"(.+?)\[0 \]");
 157:   
 158:              sb.Length = 0;
 159:   
 160:              foreach (Match o in mc) sb.Append(o.Groups[1].Captures[0].Value + "\r\n");
 161:   
 162:              s = sb.ToString();
 163:   
 164:              // below: handle hamzat wasl
 165:              s = s.Replace("[5$][1#]", "[0ٱ]");
 166:              s = s.Replace("[5$][1$]", "[0ٱ]");
 167:              s = s.Replace("[5$][1%]", "[0ٱ]");
 168:   
 169:              // below: correct character seperation of numbers
 170:              s = s.Replace("[2ÉÉ]", "[2É][2É]");
 171:              s = s.Replace("[2ÊÊ]", "[2Ê][2Ê]");
 172:              s = s.Replace("[2ËË]", "[2Ë][2Ë]");
 173:              s = s.Replace("[2ÌÌ]", "[2Ì][2Ì]");
 174:              s = s.Replace("[2ÍÍ]", "[2Í][2Í]");
 175:              s = s.Replace("[2ÎÎ]", "[2Î][2Î]");
 176:              s = s.Replace("[2ÏÏ]", "[2Ï][2Ï]");
 177:              s = s.Replace("[2ÐÐ]", "[2Ð][2Ð]");
 178:              s = s.Replace("[2ÑÑ]", "[2Ñ][2Ñ]");
 179:              s = s.Replace("[2ÒÒ]", "[2Ò][2Ò]");
 180:   
 181:              s = s.Replace("[2ÊÊÊ]", "[2Ê][2Ê][2Ê]");
 182:              s = s.Replace("[2ËËË]", "[2Ë][2Ë][2Ë]");
 183:   
 184:              s = s.Replace("[4ää]", "[4ä]");
 185:   
 186:              // below: error in "<ءاية id="2">سٓ (١ وَٱلْقُرْءَانِ ٱلْحَكِيمِ</ءاية>"
 187:              s = s.Replace("[0 ][4û][1§]\r\n[2Ê][2È]", "[4û][1§][2]\r\n[2Ç][2Ê][2È]");
 188:   
 189:              // "<ءاية id="2">مٓ (١ تَنزِيلُ ٱلْكِتَٰبِ مِنَ ٱللَّهِ ٱلْعَزِيزِ ٱلْعَلِيمِ</ءاية>"
 190:              s = s.Replace("[0 ][4ü][2N]\r\n[2Ê][2È]", "[4ü][2N][1m]\r\n[2Ç][2Ê][2È]");
 191:   
 192:              Ia.Cl.Model.File.Write("قرءان تمهيد.txt", s.ToString());
 193:          }
 194:   
 195:          ////////////////////////////////////////////////////////////////////////////
 196:   
 197:          /// <summary>
 198:          ///
 199:          /// </summary>
 200:          public static void ProcessIntermediateText2()
 201:          {
 202:              int i;
 203:              string s;
 204:              StringBuilder sb;
 205:              ArrayList al;
 206:              SortedList sl;
 207:              MatchCollection mc, word_mc;
 208:   
 209:              sb = new StringBuilder(10000000);
 210:              al = new ArrayList(100);
 211:              sl = new SortedList(300000);
 212:   
 213:              s = Ia.Cl.Model.File.Read("قرءان تمهيد.txt", System.Text.Encoding.GetEncoding(1252));
 214:   
 215:              word_mc = Regex.Matches(s, @"(.+?)\r\n");
 216:   
 217:              i = 0;
 218:   
 219:              foreach (Match o in word_mc)
 220:              {
 221:                  mc = Regex.Matches(o.Groups[1].Value, @"\[(\d)(.+?)\]");
 222:   
 223:                  al.Clear();
 224:   
 225:                  foreach (Match n in mc) al.Add(n.Groups[1].Value + n.Groups[2].Value);
 226:   
 227:                  al.Reverse();
 228:   
 229:                  sb.Length = 0;
 230:   
 231:                  sb.Append("[");
 232:   
 233:                  foreach (string t in al) sb.Append(t + ",");
 234:   
 235:                  sb.Append("][");
 236:   
 237:                  foreach (string t in al) sb.Append(Utf8(sb, t[0].ToString(), t[1].ToString()));
 238:   
 239:                  sb.Append("]");
 240:   
 241:                  sl[i++] = sb.ToString();
 242:              }
 243:   
 244:              sb.Length = 0;
 245:   
 246:              foreach (string u in sl.Values) sb.Append(u + "\r\n");
 247:   
 248:              Ia.Cl.Model.File.Write("قرءان تمهيد 2.txt", sb.ToString());
 249:          }
 250:   
 251:          ////////////////////////////////////////////////////////////////////////////
 252:   
 253:          /// <summary>
 254:          ///
 255:          /// </summary>
 256:          public static void ProcessIntermediateText2IntermediateXML()
 257:          {
 258:              int i;
 259:              string s;
 260:              StringBuilder sb;
 261:              ArrayList al;
 262:              SortedList sl;
 263:              XDocument xd;
 264:              Match m;
 265:              MatchCollection mc;
 266:   
 267:              Ia.Cl.Model.Language lang;
 268:   
 269:              sb = new StringBuilder(10000000);
 270:              al = new ArrayList(100);
 271:              sl = new SortedList(300000);
 272:   
 273:              lang = new Ia.Cl.Model.Language();
 274:   
 275:              s = Ia.Cl.Model.File.Read("قرءان تمهيد 2.txt", System.Text.Encoding.UTF8);
 276:   
 277:              mc = Regex.Matches(s, @"\[.+?\]\[(.+?)\]\r\n");
 278:   
 279:              i = 0;
 280:              sb.Length = 0;
 281:   
 282:              foreach (Match o in mc) sb.Append(o.Groups[1].Value + " ");
 283:   
 284:              s = sb.ToString();
 285:   
 286:              // below: reverse the verse numbers to display correctly
 287:              s = Regex.Replace(s, @"\((.)(.)\)", "($2$1)");
 288:              s = Regex.Replace(s, @"\((.)(.)(.)\)", "($3$2$1)");
 289:   
 290:              s = s.Replace("[5 ]", "ۙ");
 291:              s = s.Replace("[4 ]", "َّ");
 292:              s = s.Replace("[3“]", "ل");
 293:              s = s.Replace("[5­]", "۬");
 294:              s = s.Replace("[1 ]", "س");
 295:   
 296:              // below: exchange location of علامات الوقف if they come before any non space character
 297:              s = Regex.Replace(s, @"([ۖۗۘۙۚۛ])(\S)", "$2$1");
 298:   
 299:              // below: make space before علامات الوقف
 300:              s = Regex.Replace(s, @"([ۖۗۘۙۚۛ])", " $1");
 301:   
 302:              // below: make space before small و
 303:              s = s.Replace("ۥ", " ۥ");
 304:   
 305:              // below: if a small-high ى has a space (or madda) behind it we will change it just a small ى
 306:              s = s.Replace("ۧ ", " ۦ ");
 307:              s = s.Replace("ۧٓ ", "ٓ  ۦ ");
 308:   
 309:              // below: remove double spaces
 310:              s = Regex.Replace(s, @"\s+", " ");
 311:   
 312:              sb.Length = 0;
 313:   
 314:              sb.Append(@"<?xml version=""1.0"" encoding=""utf-8""?>
 315:  <قرءان lang=""ar"">
 316:  <سورة id="""" name="""">
 317:  <مقدمة />
 318:  <ءاية id="""">");
 319:   
 320:              s = Regex.Replace(s, @" \(([١٢٣٤٥٦٧٨٩٠]+)\) ", @" ($1)</ءاية>
 321:  <ءاية id="""">");
 322:   
 323:              sb.Append(s);
 324:              sb.Append(@"</ءاية>
 325:  </سورة>
 326:  </قرءان>");
 327:   
 328:              Ia.Cl.Model.File.Write("قرءان تمهيد.xml", sb.ToString());
 329:   
 330:              ///////////////////////////////
 331:              // below: process file as XML document
 332:              xd = Ia.Islamic.Koran.Wfa.Model.Data.Default.ReadFile("قرءان تمهيد.xml");
 333:   
 334:              // below: setup verse values
 335:              foreach (XElement xe in xd.Descendants("قرءان").Descendants("سورة").Descendants("ءاية"))
 336:              {
 337:                  m = Regex.Match(xe.Value, @"\(([١٢٣٤٥٦٧٨٩٠]{1,3})\)");
 338:   
 339:                  if (m.Success)
 340:                  {
 341:                      s = m.Groups[1].Captures[0].Value;
 342:                      xe.Value = xe.Value.Replace(" (" + s + ")", "");
 343:                      s = Ia.Cl.Model.Language.ConvertArabicNumbersToLatin(s);
 344:                      // needs fixing xe.Attributes("id"). = s;
 345:                  }
 346:              }
 347:   
 348:              // below:
 349:              // Ia.Cl.Model.Xml.WriteXmlNode(xd, "قرءان تمهيد.xml");
 350:              xd.Save(Ia.Cl.Model.Default.AbsolutePath() + "قرءان تمهيد.xml");
 351:   
 352:              ///////////////////////////////
 353:              // below: now open as text file
 354:              s = Ia.Cl.Model.File.Read("قرءان تمهيد.xml", System.Text.Encoding.UTF8);
 355:   
 356:              s = s.Replace(@"<ءاية id=""1"">", @"</سورة>
 357:  <سورة id="""" name="""">
 358:  <مقدمة />
 359:  <ءاية id=""1"">");
 360:   
 361:              // below: remove
 362:              s = s.Replace(@"<سورة id="""" name=""""><مقدمة /></سورة>", "");
 363:              s = s.Replace(@"<ءاية id=""""></ءاية>", "");
 364:   
 365:              // below: add a number of missing verses from the original file
 366:   
 367:              s = s.Replace(@"<ءاية id=""162"">قُلْ إِنَّ صَلاَتِى وَنُسُكِى وَمَحْيَاىَ وَمَمَاتِى لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ</ءاية>", @"<ءاية id=""162"">قُلْ إِنَّ صَلاَتِى وَنُسُكِى وَمَحْيَاىَ وَمَمَاتِى لِلَّهِ رَبِّ ٱلْعَٰلَمِينَ</ءاية>
 368:  <ءاية id=""163"">لاَ شَرِيكَ لَهُ ۥ ۖ وَبِذَٰلِكَ أُمِرْتُ وَأَنَاْ أَوَّلُ ٱلْمُسْلِمِينَ</ءاية>
 369:  <ءاية id=""164"">قُلْ أَغَيْرَ ٱللَّهِ أَبْغِي رَبًّا وَهُوَ رَبُّ كُلِّ شَيْءٍ ۚ وَلاَ تَكْسِبُ كُلُّ نَفْسٍ إِلاَّ عَلَيْهَا ۚ وَلاَ تَزِرُ وَازِرَةٌ وِزْرَ أُخْرَىٰ ۚ ثُمَّ إِلَى رَبِّكُم مَّرْجِعُكُمْ فَيُنَبِّئُكُم بِمَا كُنتُمْ فِيهِ تَخْتَلِفُونَ</ءاية>
 370:  <ءاية id=""165"">وَهُوَ ٱلَّذِي جَعَلَكُمْ خَلَٰٓئِفَ ٱلْأَرْضِ وَرَفَعَ بَعْضَكُمْ فَوْقَ بَعْضٍ دَرَجَٰتٍ لِّيَبْلُوَكُمْ فِي مَآ ءَاتَٰكُمْ ۗ  إِنَّ رَبَّكَ سَرِيعُ ٱلْعِقَابِ وَإِنَّهُ ۥ لَغَفُورٌ رَّحِيمٌ</ءاية>");
 371:   
 372:              Ia.Cl.Model.File.Write("قرءان تمهيد.xml", s);
 373:   
 374:              ///////////////////////////////
 375:              // below: process file as XML document
 376:              i = 1;
 377:              xd = Ia.Islamic.Koran.Wfa.Model.Data.Default.ReadFile("قرءان تمهيد.xml");
 378:   
 379:              // below:
 380:              foreach (XElement xe in xd.Descendants("قرءان").Descendants("سورة"))
 381:              {
 382:                  // fix xe.Attributes("id").Value = i.ToString();
 383:                  i++;
 384:              }
 385:   
 386:              // below:
 387:              // Ia.Cl.Model.Xml.WriteXmlNode(xd, "قرءان تمهيد.xml");
 388:              xd.Save(Ia.Cl.Model.Default.AbsolutePath() + "قرءان تمهيد.xml");
 389:          }
 390:   
 391:          ////////////////////////////////////////////////////////////////////////////
 392:   
 393:          /// <summary>
 394:          ///
 395:          /// </summary>
 396:          public static bool ProcessIntermediateXMLFinalXML()
 397:          {
 398:              bool b;
 399:              //string s;
 400:              XDocument xd, ar_xd;
 401:   
 402:              ar_xd = Ia.Islamic.Koran.Wfa.Model.Data.Default.ReadFile(@"ar.xml");
 403:              xd = Ia.Islamic.Koran.Wfa.Model.Data.Default.ReadFile("قرءان تمهيد.xml");
 404:   
 405:              b = true;
 406:   
 407:              // below: copy chapter names to new file
 408:              foreach (XElement xe in xd.Descendants("قرءان").Descendants("سورة"))
 409:              {
 410:                  // fix s =  xe.Attributes("id").Value;
 411:   
 412:                  // below: check if verse numbers are same
 413:   
 414:                  /* fix
 415:                  if (xe.SelectNodes("ءاية").Count == ar_xd.SelectNodes("قرءان/سورة[@id='" + s + "']/ءاية").Count)
 416:                  {
 417:                      xe.Attributes["name"].Value = ar_xd.SelectSingleNode("قرءان/سورة[@id='" + s + "']").Attributes["name"].Value;
 418:                  }
 419:                  else
 420:                  {
 421:                      b = false;
 422:                  }
 423:                  */
 424:              }
 425:   
 426:              if (b)
 427:              {
 428:                  // below:
 429:                  //Ia.Cl.Model.Xml.WriteXmlNode(xd, "قرءان نهائي.xml");
 430:                  xd.Save(Ia.Cl.Model.Default.AbsolutePath() + "قرءان نهائي.xml");
 431:              }
 432:   
 433:              return b;
 434:          }
 435:   
 436:          ////////////////////////////////////////////////////////////////////////////
 437:   
 438:          /// <summary>
 439:          /// Convert 
 440:          /// </summary>
 441:          public static string Utf8(StringBuilder sb, string fontFamily, string s)
 442:          {
 443:              char c, h;
 444:              string u;
 445:   
 446:              count++;
 447:   
 448:              c = h = '0';
 449:   
 450:              u = null;
 451:   
 452:              if (s.Length == 1)
 453:              {
 454:                  c = s.ToCharArray()[0];
 455:   
 456:                  h = c;
 457:   
 458:                  if (fontFamily == "1")
 459:                  {
 460:                      if (c == 33) u = "لله";
 461:                      // else if (c == 34) u = "";
 462:                      else if (c == 35 || c == 36 || c == 37) u = "ا";
 463:                      else if (c == 38 || c == 39 || c == 40) u = "أ";
 464:                      else if (c == 41 || c == 42 || c == 43) u = "إ";
 465:                      else if (c >= 44 && c <= 46) u = "اۤ";
 466:                      else if (c >= 47 && c <= 62) u = "ب";
 467:                      else if (c >= 63 && c <= 78) u = "ت";
 468:                      else if (c >= 79 && c <= 94) u = "ث";
 469:                      else if (c >= 95 && c <= 108 && c != 97) u = "ج";
 470:                      else if (c >= 109 && c <= 121) u = "ح";
 471:                      else if (c >= 122 && c <= 136 && c != 127 && c != 128) u = "خ";
 472:                      else if (c == 137 || c == 138) u = "د";
 473:                      else if (c == 139 || c == 140) u = "ذ";
 474:                      else if (c >= 141 && c <= 146) u = "ر";
 475:                      else if (c >= 147 && c <= 152) u = "ز";
 476:                      else if (c >= 153 && c <= 168 && c != 160) u = "س";
 477:                      else if (c >= 169 && c <= 184 /*&& c != 173*/) u = "ش";
 478:                      else if (c >= 185 && c <= 201) u = "ص";
 479:                      else if (c >= 202 && c <= 218) u = "ض";
 480:                      else if (c >= 219 && c <= 222) u = "ط";
 481:                      else if (c >= 223 && c <= 226) u = "ظ";
 482:                      else if (c >= 227 && c <= 237) u = "ع";
 483:                      else if (c >= 238 && c <= 248) u = "غ";
 484:                      else if (c >= 249 && c <= 255 && c != 253 && c != 254) u = "ف";
 485:                      else
 486:                      {
 487:                          u = "Error: letter '" + c + "' not recognized. ";
 488:                      }
 489:                  }
 490:                  else if (fontFamily == "2")
 491:                  {
 492:                      if (c >= 33 && c <= 36) u = "ف";
 493:                      else if (c >= 37 && c <= 45) u = "ق";
 494:                      else if (c >= 46 && c <= 56) u = "ك";
 495:                      else if (c >= 57 && c <= 65) u = "ل";
 496:                      else if (c >= 66 && c <= 81) u = "م";
 497:                      else if (c >= 82 && c <= 99 && c != 97) u = "ن";
 498:                      else if (c >= 100 && c <= 110) u = "ه";
 499:                      else if (c == 111 || c == 112) u = "ة";
 500:                      else if (c == 113 || c == 114) u = "و";
 501:                      else if (c == 115 || c == 116) u = "ؤ";
 502:                      else if (c == 117 || c == 118) u = "وٕ";
 503:                      else if (c == 119 || c == 120) u = "لا";
 504:                      else if (c >= 121 && c <= 124) u = "لأ";
 505:                      else if (c == 125 || c == 126) u = "لإ";
 506:   
 507:                      else if (c == 129 || c == 130) u = "لآ";
 508:                      else if (c >= 131 && c <= 144) u = "ي";
 509:                      else if (c >= 145 && c <= 148) u = "ى";
 510:                      else if (c >= 149 && c <= 152) u = "ئ";
 511:                      else if (c >= 153 && c <= 156) u = "ىء";
 512:                      else if (c >= 157 && c <= 171 && c != 160) u = "ئ";
 513:                      else if (c == 172 || c >= 174 && c <= 185) u = "ئ";
 514:                      else if (c == 186 || c == 187) u = "ٰ";
 515:                      else if (c == 188) u = "ۥ";
 516:                      else if (c == 189) u = "ۥ";
 517:                      else if (c == 190 || c == 191) u = "ۧ";
 518:                      else if (c == 192 || c == 193) u = "ٰٔ";
 519:                      else if (c == 194 || c == 195) u = "ٰٓ";
 520:                      else if (c == 197) u = "ٰ";
 521:                      else if (c == 198) u = "ن";
 522:                      else if (c == 199) u = ")";
 523:                      else if (c == 200) u = "(";
 524:                      else if (c == 201) u = "٠";
 525:                      else if (c == 202) u = "١";
 526:                      else if (c == 203) u = "٢";
 527:                      else if (c == 204) u = "٣";
 528:                      else if (c == 205) u = "٤";
 529:                      else if (c == 206) u = "٥";
 530:                      else if (c == 207) u = "٦";
 531:                      else if (c == 208) u = "٧";
 532:                      else if (c == 209) u = "٨";
 533:                      else if (c == 210) u = "٩";
 534:                      else if (c == 211) u = "ى";
 535:                      else if (c == 212) u = "خ";
 536:                      else if (c == 213) u = "ح";
 537:                      else if (c == 214) u = "ج";
 538:                      else if (c == 215 || c == 216) u = "ئ";
 539:                      else if (c == 217 || c == 218) u = "ج";
 540:                      else if (c == 219) u = "ح";
 541:                      else if (c == 220) u = "خ";
 542:                      else if (c == 221 || c == 222) u = "ص";
 543:                      else if (c == 223 || c == 224) u = "ض";
 544:                      else if (c == 228) u = "ء";
 545:                      else if (c == 229) u = "ٰ";
 546:                      else if (c == 230 || c == 231) u = "ئ";
 547:                      else if (c == 232) u = "ن";
 548:                      else if (c == 233) u = "ث";
 549:                      else if (c == 234) u = "ت";
 550:                      else if (c == 235) u = "ب";
 551:                      else if (c == 236) u = "ي";
 552:                      else if (c == 237 || c == 238) u = "ئ";
 553:                      else if (c == 239) u = "ي";
 554:                      else if (c == 240) u = "ن";
 555:                      else if (c == 241) u = "ث";
 556:                      else if (c == 242) u = "ت";
 557:                      else if (c == 243) u = "ب";
 558:                      else if (c == 244 || c == 245) u = "ئ";
 559:                      else if (c == 246) u = "ن";
 560:                      else if (c == 247) u = "ث";
 561:                      else if (c == 248) u = "ت";
 562:                      else if (c == 249) u = "ب";
 563:                      else if (c == 250 || c == 251) u = "ن";
 564:                      else if (c == 252) u = "ي";
 565:                      else if (c == 255) u = "م";
 566:                      else
 567:                      {
 568:                          u = "Error: letter '" + c + "' not recognized. ";
 569:                      }
 570:                  }
 571:                  else if (fontFamily == "3")
 572:                  {
 573:                      if (c == 32) u = "ه";
 574:                      else if (c == 33) u = "ل";
 575:                      else if (c == 35) u = "ل";
 576:                      else if (c == 36) u = "د";
 577:                      else if (c == 37) u = "ذ";
 578:                      else if (c == 38) u = "ه";
 579:                      else if (c == 39) u = "ة";
 580:                      else if (c == 40) u = "ب";
 581:                      else if (c == 41) u = "ت";
 582:                      else if (c == 42) u = "ث";
 583:                      else if (c == 43) u = "ن";
 584:                      else if (c == 44) u = "ي";
 585:                      else if (c == 45 || c == 46) u = "ئ";
 586:                      else if (c == 47) u = "م";
 587:                      else if (c == 48) u = "ه";
 588:                      else if (c >= 49 && c <= 62) u = "ٰ";
 589:   
 590:                      else if (c == 71) u = "ۨ";
 591:                      else if (c == 72 || c == 73) u = "ٰ";
 592:                      else if (c == 74) u = "س";
 593:                      else if (c == 75) u = "ش";
 594:                      else if (c == 76) u = "ص";
 595:                      else if (c == 77) u = "ض";
 596:                      else if (c == 78) u = "س";
 597:                      else if (c == 79) u = "ش";
 598:                      else if (c == 80) u = "ٰ";
 599:                      else if (c == 81) u = "ل";
 600:                      else if (c == 82) u = "م";
 601:                      else if (c == 83) u = "ه";
 602:   
 603:                      else if (c == 84) u = "لله";
 604:   
 605:                      else if (c == 85) u = "ب";
 606:                      else if (c == 86) u = "ت";
 607:                      else if (c == 87) u = "ث";
 608:                      else if (c == 88) u = "ق";
 609:                      else if (c == 89) u = "ق";
 610:                      else if (c == 90) u = "س";
 611:                      else if (c == 91) u = "س";
 612:                      else if (c == 92) u = "ش";
 613:                      else if (c == 93) u = "ش";
 614:                      else if (c == 94) u = "ل";
 615:                      else if (c == 95) u = "ى";
 616:                      else if (c == 96) u = "ئ";
 617:                      else if (c == 98) u = "ئ";
 618:                      else if (c == 108) u = "ك";
 619:   
 620:                      else if (c == 109) u = "ب";
 621:                      else if (c == 110) u = "ت";
 622:                      else if (c == 111) u = "ث";
 623:                      else if (c == 112) u = "ن";
 624:                      else if (c == 113) u = "ي";
 625:                      else if (c == 114) u = "ئ";
 626:                      else if (c == 115) u = "ئ";
 627:                      else if (c == 116) u = "ٰ";
 628:   
 629:                      else if (c == 118) u = "ب";
 630:                      else if (c == 119) u = "ت";
 631:                      else if (c == 120) u = "ث";
 632:                      else if (c == 121) u = "ن";
 633:                      else if (c == 122) u = "ي";
 634:                      else if (c == 123) u = "ئ";
 635:                      else if (c == 124) u = "ئ";
 636:                      else if (c == 125) u = "ٰ";
 637:   
 638:                      else if (c == 129 || c == 130) u = "ك";
 639:                      else if (c == 131) u = "ع";
 640:                      else if (c == 132) u = "م";
 641:                      else if (c == 133) u = "ه";
 642:   
 643:                      else if (c == 134) u = "ى";
 644:                      else if (c == 135 || c == 136) u = "ئ";
 645:                      else if (c == 137) u = "ه";
 646:   
 647:                      else if (c == 138) u = "س";
 648:                      else if (c == 139) u = "ش";
 649:                      else if (c == 140) u = "ص";
 650:                      else if (c == 141) u = "ض";
 651:   
 652:                      else if (c == 142) u = "س";
 653:                      else if (c == 143) u = "ش";
 654:                      else if (c == 144) u = "ص";
 655:                      else if (c == 145) u = "ض";
 656:   
 657:                      else if (c == 146) u = "ف";
 658:                      else if (c == 148) u = "ع";
 659:   
 660:                      else if (c >= 149 && c <= 255 && c != 160 && c != 173 && c != 253 && c != 254) u = "ء";
 661:   
 662:                      else
 663:                      {
 664:                          u = "Error: letter '" + c + "' not recognized. ";
 665:                      }
 666:                  }
 667:                  else if (fontFamily == "4")
 668:                  {
 669:                      if (c == 33) u = "ۜ";
 670:                      else if (c == 34) u = "ۗ";
 671:                      else if (c == 35) u = "ۚ";
 672:                      else if (c == 36) u = "ٓ";
 673:                      else if (c == 37 || c == 38) u = "ٍ";
 674:                      else if (c == 39) u = "ٓ";
 675:                      else if (c == 40) u = "ۖ";
 676:                      else if (c == 41) u = " "; //"۩";
 677:                      else if (c == 42) u = " "; //"۞";
 678:   
 679:                      else if (c == 43 || c == 44) u = "ًً";
 680:                      else if (c == 45) u = "ًً";
 681:                      else if (c == 47) u = "ًَ";
 682:                      else if (c == 48) u = "ًً";
 683:   
 684:                      else if (c == 50) u = "ۜ";
 685:                      else if (c == 51) u = "ۗ";
 686:                      else if (c == 52) u = "ۚ";
 687:                      else if (c == 53) u = "ٍ";
 688:                      else if (c == 54) u = "َ۟";
 689:                      else if (c >= 55 && c <= 68) u = "ٍ";
 690:                      else if (c >= 69 && c <= 82) u = "َۢ";
 691:                      else if (c >= 83 && c <= 94) u = "ً";
 692:                      else if (c >= 95 && c <= 113) u = "ّ";
 693:                      else if (c >= 114 && c <= 140 && c != 127) u = "ًّ";
 694:                      else if (c >= 141 && c <= 157) u = "ُّ";
 695:                      else if (c == 158 || c >= 161 && c <= 176) u = "َّ"; // 173 included
 696:                      else if (c >= 177 && c <= 188) u = "ً";
 697:                      else if (c >= 189 && c <= 207) u = "ِ";
 698:                      else if (c >= 208 && c <= 216) u = "ٌ";
 699:                      else if (c >= 217 && c <= 233) u = "ُ";
 700:                      else if (c >= 234 && c <= 238) u = "ٌ";
 701:                      else if (c >= 239 && c <= 249) u = "ْ";
 702:                      else if (c >= 250 && c <= 255) u = "ٓ";
 703:                      else
 704:                      {
 705:                          u = "Error: letter '" + c + "' not recognized. ";
 706:                      }
 707:                  }
 708:                  else if (fontFamily == "5")
 709:                  {
 710:                      if (c == 33) u = "ٓ";
 711:                      else if (c == 34 || c == 35) u = "ٰٓ";
 712:                      //else if (c == 36) u = "ﭐ";
 713:                      else if (c >= 37 && c <= 40) u = "۟";
 714:                      else if (c == 41 || c == 42) u = "ْۜ";
 715:                      else if (c == 43 || c == 44) u = "ُۜ";
 716:                      else if (c >= 45 && c <= 47) u = "ۢ";
 717:                      else if (c == 48) u = "َ۫";
 718:                      else if (c == 49) u = "۪";
 719:                      else if (c >= 50 && c <= 52) u = "ٰ";
 720:                      else if (c >= 53 && c <= 57) u = "ُۢ";
 721:                      else if (c >= 58 && c <= 60) u = "ٌّ";
 722:                      else if (c == 61 || c == 62) u = "َۜ";
 723:                      else if (c >= 63 && c <= 65) u = "ٌّ";
 724:                      else if (c == 66) u = "َّۢ";
 725:                      else if (c == 67 || c == 68) u = "َّۢ";
 726:                      else if (c == 69 || c == 70) addAccent(ref sb, "ْ", "َ");
 727:                      else if (c == 71 || c == 72) addAccent(ref sb, "َّ", "ٓ");
 728:                      else if (c == 73 || c == 74) addAccent(ref sb, "َ", "ٓ");
 729:                      else if (c == 75 || c == 76) addAccent(ref sb, "ِ", "َ");
 730:                      else if (c == 77 || c == 78) addAccent(ref sb, "ْ", "ِ");
 731:                      else if (c == 79 || c == 80) u = "۟";
 732:                      else if (c >= 81 && c <= 83) u = "ٍّ";
 733:                      else if (c == 84) addAccent(ref sb, "ِ", "ّ");
 734:                      else if (c == 85 || c == 86) addAccent(ref sb, "َ", "َ");
 735:                      else if (c == 87) addAccent(ref sb, "ْ", "ُ");
 736:                      else if (c == 88) addAccent(ref sb, "ِّ", "َ");
 737:                      else if (c == 89 || c == 90) addAccent(ref sb, "َ", "ِ");
 738:                      else if (c == 91) addAccent(ref sb, "ِّ", "ُ");
 739:                      else if (c == 92) addAccent(ref sb, "ِ", "ِ");
 740:                      else if (c == 93) addAccent(ref sb, "َ", "ْ");
 741:                      else if (c == 94) addAccent(ref sb, "َّ", "ْ");
 742:                      else if (c == 95) addAccent(ref sb, "َ", "ُ");
 743:                      else if (c == 96 || c == 97) addAccent(ref sb, "َّ", "َ");
 744:                      else if (c == 98) addAccent(ref sb, "ِّ", "ِ");
 745:                      else if (c == 99) addAccent(ref sb, "َّ", "ُ");
 746:                      else if (c == 100) addAccent(ref sb, "َ", "ٌ");
 747:                      else if (c == 101) addAccent(ref sb, "ِ", "ْ");
 748:                      else if (c == 102 || c == 103) addAccent(ref sb, "َ", "۠");
 749:                      else if (c == 104) addAccent(ref sb, "َ", "ْ");
 750:                      else if (c == 105) u = "َ۫";
 751:                      else if (c == 106) addAccent(ref sb, "ۣ", "َ");
 752:                      else if (c == 107) u = "َۣ";
 753:                      else if (c == 108) u = "ِّۭ";
 754:                      else if (c >= 109 && c <= 154 && c != 127) u = "َ";
 755:                      else if (c == 155) u = "ُّۢ";
 756:                      else if (c == 156) u = "َّ";
 757:                      else if (c == 157) u = "ِ";
 758:                      else if (c == 158) u = "َّ";
 759:                      else if (c == 159) u = "َ";
 760:                      else if (c == 161) u = "ۛ"; // "؞"
 761:                      else if (c == 162) u = "ۘ";
 762:                      else if (c >= 163 && c <= 165) u = "ِۭ";
 763:                      else if (c == 166) u = "ٰٓ";
 764:                      else if (c == 167) u = "ٰٔ";
 765:                      else if (c == 168) u = "ٰ";
 766:                      else if (c == 169) addAccent(ref sb, "َّ", "َ");
 767:                      else if (c == 170) addAccent(ref sb, "َّ", "ُ");
 768:                      else if (c == 171) addAccent(ref sb, "َّ", "ِ");
 769:                      else if (c == 172) addAccent(ref sb, "ِ", "َّ", "ِ");
 770:                      else if (c == 174) u = "۬";
 771:                      else if (c == 175) u = "ٓ";
 772:                      else if (c == 176) addAccent(ref sb, "ِّ", "َّ", "ِ");
 773:                      else if (c >= 177 && c <= 251) u = " "; //"۞";
 774:                      else
 775:                      {
 776:                          u = "Error: letter '" + c + "' not recognized. ";
 777:                      }
 778:                  }
 779:                  else if (fontFamily == "0")
 780:                  {
 781:                      u = c.ToString();
 782:                  }
 783:                  else
 784:                  {
 785:                      u = "Error: font family undefined. ";
 786:                  }
 787:              }
 788:              else
 789:              {
 790:                  u = "Error: char array is more than 1 char. ";
 791:              }
 792:   
 793:              if (u != null && u.Contains("Error"))
 794:              {
 795:                  fix_ht[fontFamily + " " + h] = 1;
 796:   
 797:                  //u = "[" + font_family + s + ":" + (int)c + "]";
 798:                  u = "[" + fontFamily + s + "]";
 799:              }
 800:   
 801:              return u;
 802:          }
 803:   
 804:          ////////////////////////////////////////////////////////////////////////////
 805:   
 806:          /// <summary>
 807:          ///
 808:          /// </summary>
 809:          public static void addAccent(ref StringBuilder sb, string first, string second)
 810:          {
 811:              // below: add certain accents to he privious letters
 812:   
 813:              sb.Insert(sb.Length - 1, first);
 814:              sb.Insert(sb.Length, second);
 815:          }
 816:   
 817:          ////////////////////////////////////////////////////////////////////////////
 818:   
 819:          /// <summary>
 820:          ///
 821:          /// </summary>
 822:          public static void addAccent(ref StringBuilder sb, string first, string second, string third)
 823:          {
 824:              // below: add certain accents to he privious letters
 825:   
 826:              sb.Insert(sb.Length - 2, first);
 827:              sb.Insert(sb.Length - 1, second);
 828:              sb.Insert(sb.Length, third);
 829:          }
 830:   
 831:          ////////////////////////////////////////////////////////////////////////////
 832:          ////////////////////////////////////////////////////////////////////////////
 833:      }
 834:   
 835:      ////////////////////////////////////////////////////////////////////////////
 836:      ////////////////////////////////////////////////////////////////////////////
 837:  }