)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Preparation (Ia.Islamic.Koran.Wfa.Model.Business)

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