PRUint32 endNumeral, beginNumeral;
PRUint32 endNumeral, beginNumeral = 0;
nsresult Conv_06_FE_WithReverse(const nsString& aSrc,                                nsString& aDst,                                PRUint32 aDir){  PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();  PRUint32 i,beginArabic, endArabic, size = aSrc.Length();  aDst.Truncate();  PRBool foundArabic = PR_FALSE;  for (endArabic=0;endArabic<size;endArabic++) {    if (aSrcUnichars[endArabic] == 0x0000)       break; // no need to convert char after the NULL    while( (IS_06_CHAR(aSrcUnichars[endArabic])) ||            (IS_ARABIC_CHAR(aSrcUnichars[endArabic])) ||            (aSrcUnichars[endArabic]==0x0020) ||            (IS_ARABIC_DIGIT(aSrcUnichars[endArabic]))  )     {      if(! foundArabic) {        beginArabic=endArabic;        foundArabic=PR_TRUE;      }      endArabic++;    }    if(foundArabic) {      endArabic--;      PRUnichar buf[8192];      PRUint32 len=8192;      ArabicShaping(&aSrcUnichars[beginArabic], endArabic-beginArabic+1,                    buf, &len,                     PR_TRUE, PR_FALSE);      // to reverse the numerals      PRUint32 endNumeral, beginNumeral;      for (endNumeral=0;endNumeral<=len-1;endNumeral++){        PRBool foundNumeral = PR_FALSE;        while((endNumeral < len) && (IS_ARABIC_DIGIT(buf[endNumeral]))  ) {          if(!foundNumeral)          {            foundNumeral=PR_TRUE;            beginNumeral=endNumeral;          }          endNumeral++;        }        if(foundNumeral){          endNumeral--;          PRUnichar numbuf[20];          for(i=beginNumeral; i<=endNumeral; i++){            numbuf[i-beginNumeral]=buf[endNumeral-i+beginNumeral];          }          for(i=0;i<=endNumeral-beginNumeral;i++){            buf[i+beginNumeral]=numbuf[i];          }        }      }      if(aDir==1){//ltr        for (i=0;i<=len-1;i++){          aDst+= buf[i];        }       }      else if(aDir==2){//rtl        for (i=0;i<=len-1;i++){          aDst+= buf[len-1-i];        }       }    } else {      aDst += aSrcUnichars[endArabic];    }    foundArabic=PR_FALSE;  }// for : loop the buffer  return NS_OK;}