Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsBidiUtils.h File Reference
#include "nsCOMPtr.h"
#include "nsString.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define IBMBIDI_TEXTDIRECTION_STR   "bidi.direction"
#define IBMBIDI_TEXTTYPE_STR   "bidi.texttype"
#define IBMBIDI_CONTROLSTEXTMODE_STR   "bidi.controlstextmode"
#define IBMBIDI_NUMERAL_STR   "bidi.numeral"
#define IBMBIDI_SUPPORTMODE_STR   "bidi.support"
#define IBMBIDI_CHARSET_STR   "bidi.characterset"
#define IBMBIDI_TEXTDIRECTION   1
#define IBMBIDI_TEXTTYPE   2
#define IBMBIDI_CONTROLSTEXTMODE   3
#define IBMBIDI_NUMERAL   4
#define IBMBIDI_SUPPORTMODE   5
#define IBMBIDI_CHARSET   6
#define IBMBIDI_TEXTDIRECTION_LTR   1
#define IBMBIDI_TEXTDIRECTION_RTL   2
#define IBMBIDI_TEXTTYPE_CHARSET   1
#define IBMBIDI_TEXTTYPE_LOGICAL   2
#define IBMBIDI_TEXTTYPE_VISUAL   3
#define IBMBIDI_CONTROLSTEXTMODE_LOGICAL   1
#define IBMBIDI_CONTROLSTEXTMODE_VISUAL   2
#define IBMBIDI_CONTROLSTEXTMODE_CONTAINER   3
#define IBMBIDI_NUMERAL_NOMINAL   0
#define IBMBIDI_NUMERAL_REGULAR   1
#define IBMBIDI_NUMERAL_HINDICONTEXT   2
#define IBMBIDI_NUMERAL_ARABIC   3
#define IBMBIDI_NUMERAL_HINDI   4
#define IBMBIDI_SUPPORTMODE_MOZILLA   1
#define IBMBIDI_SUPPORTMODE_OSBIDI   2
#define IBMBIDI_SUPPORTMODE_DISABLE   3
#define IBMBIDI_CHARSET_BIDI   1
#define IBMBIDI_CHARSET_DEFAULT   2
#define IBMBIDI_DEFAULT_BIDI_OPTIONS
#define GET_BIDI_OPTION_DIRECTION(bo)   (((bo)>>0) & 0x0000000F) /* 4 bits for DIRECTION */
#define GET_BIDI_OPTION_TEXTTYPE(bo)   (((bo)>>4) & 0x0000000F) /* 4 bits for TEXTTYPE */
#define GET_BIDI_OPTION_CONTROLSTEXTMODE(bo)   (((bo)>>8) & 0x0000000F) /* 4 bits for CONTROLTEXTMODE */
#define GET_BIDI_OPTION_NUMERAL(bo)   (((bo)>>12) & 0x0000000F) /* 4 bits for NUMERAL */
#define GET_BIDI_OPTION_SUPPORT(bo)   (((bo)>>16) & 0x0000000F) /* 4 bits for SUPPORT */
#define GET_BIDI_OPTION_CHARACTERSET(bo)   (((bo)>>20) & 0x0000000F) /* 4 bits for CHARACTERSET */
#define SET_BIDI_OPTION_DIRECTION(bo, dir)   {(bo)=((bo) & 0xFFFFFFF0)|(((dir)& 0x0000000F)<<0);}
#define SET_BIDI_OPTION_TEXTTYPE(bo, tt)   {(bo)=((bo) & 0xFFFFFF0F)|(((tt)& 0x0000000F)<<4);}
#define SET_BIDI_OPTION_CONTROLSTEXTMODE(bo, cotm)   {(bo)=((bo) & 0xFFFFF0FF)|(((cotm)& 0x0000000F)<<8);}
#define SET_BIDI_OPTION_NUMERAL(bo, num)   {(bo)=((bo) & 0xFFFF0FFF)|(((num)& 0x0000000F)<<12);}
#define SET_BIDI_OPTION_SUPPORT(bo, sup)   {(bo)=((bo) & 0xFFF0FFFF)|(((sup)& 0x0000000F)<<16);}
#define SET_BIDI_OPTION_CHARACTERSET(bo, cs)   {(bo)=((bo) & 0xFF0FFFFF)|(((cs)& 0x0000000F)<<20);}
#define START_HINDI_DIGITS   0x0660
#define END_HINDI_DIGITS   0x0669
#define START_ARABIC_DIGITS   0x0030
#define END_ARABIC_DIGITS   0x0039
#define START_FARSI_DIGITS   0x06f0
#define END_FARSI_DIGITS   0x06f9
#define IS_HINDI_DIGIT(u)   ( ( (u) >= START_HINDI_DIGITS ) && ( (u) <= END_HINDI_DIGITS ) )
#define IS_ARABIC_DIGIT(u)   ( ( (u) >= START_ARABIC_DIGITS ) && ( (u) <= END_ARABIC_DIGITS ) )
#define IS_FARSI_DIGIT(u)   ( ( (u) >= START_FARSI_DIGITS ) && ( (u) <= END_FARSI_DIGITS ) )
#define IS_ARABIC_SEPARATOR(u)   ( ( (u) == 0x066A ) || ( (u) == 0x066B ) || ( (u) == 0x066C ) )
#define IS_BIDI_DIACRITIC(u)
#define IS_HEBREW_CHAR(c)   (((0x0590 <= (c)) && ((c)<= 0x05FF)) || (((c) >= 0xfb1d) && ((c) <= 0xfb4f)))
#define IS_06_CHAR(c)   ((0x0600 <= (c)) && ((c)<= 0x06FF))
#define IS_FE_CHAR(c)
#define IS_ARABIC_CHAR(c)   ((0x0600 <= (c)) && ((c)<= 0x06FF))
#define IS_ARABIC_ALPHABETIC(c)
#define IS_BIDI_CONTROL_CHAR(c)
#define IS_IN_BMP_RTL_BLOCK(c)   ((0x590 <= (c)) && ((c) <= 0x8ff))
 The codepoint ranges in the following macros are based on the blocks allocated, or planned to be allocated, to right-to-left characters in the BMP (Basic Multilingual Plane) and SMP (Supplementary Multilingual Plane) according to http://unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt and http://www.unicode.org/roadmaps/.
#define IS_RTL_PRESENTATION_FORM(c)
#define IS_IN_SMP_RTL_BLOCK(c)   ((0x10800 <= (c)) && ((c) <= 0x10fff))
#define UCS2_CHAR_IS_BIDI(c)
#define UTF32_CHAR_IS_BIDI(c)

Functions

nsresult ArabicShaping (const PRUnichar *aString, PRUint32 aLen, PRUnichar *aBuf, PRUint32 *aBufLen, PRBool aInputLogical, PRBool aOutputLogical)
 Perform Arabic shaping on a Unichar string.
nsresult Conv_FE_06 (const nsString &aSrc, nsString &aDst)
 Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx range.
nsresult Conv_FE_06_WithReverse (const nsString &aSrc, nsString &aDst)
 Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx range, and also reverse the string.
nsresult Conv_06_FE_WithReverse (const nsString &aSrc, nsString &aDst, PRUint32 aDir)
 Scan an nsString, converting characters in the 06xx range to the equivalent characters in the 0Fxx range (Arabic presentation forms), with the option to reverse the string.
nsresult HandleNumbers (PRUnichar *aBuffer, PRUint32 aSize, PRUint32 aNumFlag)
 Scan a Unichar string, converting numbers to Arabic or Hindi forms in place.
nsresult HandleNumbers (const nsString &aSrc, nsString &aDst)
 Scan an nsString, converting numerals to Arabic or Hindi forms.

Define Documentation

#define END_ARABIC_DIGITS   0x0039

Definition at line 201 of file nsBidiUtils.h.

#define END_FARSI_DIGITS   0x06f9

Definition at line 203 of file nsBidiUtils.h.

#define END_HINDI_DIGITS   0x0669

Definition at line 199 of file nsBidiUtils.h.

#define GET_BIDI_OPTION_CHARACTERSET (   bo)    (((bo)>>20) & 0x0000000F) /* 4 bits for CHARACTERSET */

Definition at line 188 of file nsBidiUtils.h.

#define GET_BIDI_OPTION_CONTROLSTEXTMODE (   bo)    (((bo)>>8) & 0x0000000F) /* 4 bits for CONTROLTEXTMODE */

Definition at line 185 of file nsBidiUtils.h.

#define GET_BIDI_OPTION_DIRECTION (   bo)    (((bo)>>0) & 0x0000000F) /* 4 bits for DIRECTION */

Definition at line 183 of file nsBidiUtils.h.

#define GET_BIDI_OPTION_NUMERAL (   bo)    (((bo)>>12) & 0x0000000F) /* 4 bits for NUMERAL */

Definition at line 186 of file nsBidiUtils.h.

#define GET_BIDI_OPTION_SUPPORT (   bo)    (((bo)>>16) & 0x0000000F) /* 4 bits for SUPPORT */

Definition at line 187 of file nsBidiUtils.h.

#define GET_BIDI_OPTION_TEXTTYPE (   bo)    (((bo)>>4) & 0x0000000F) /* 4 bits for TEXTTYPE */

Definition at line 184 of file nsBidiUtils.h.

Definition at line 129 of file nsBidiUtils.h.

Definition at line 171 of file nsBidiUtils.h.

Definition at line 172 of file nsBidiUtils.h.

#define IBMBIDI_CHARSET_STR   "bidi.characterset"

Definition at line 122 of file nsBidiUtils.h.

Definition at line 126 of file nsBidiUtils.h.

Definition at line 150 of file nsBidiUtils.h.

Definition at line 148 of file nsBidiUtils.h.

#define IBMBIDI_CONTROLSTEXTMODE_STR   "bidi.controlstextmode"

Definition at line 119 of file nsBidiUtils.h.

Definition at line 149 of file nsBidiUtils.h.

Definition at line 127 of file nsBidiUtils.h.

Definition at line 158 of file nsBidiUtils.h.

Definition at line 159 of file nsBidiUtils.h.

Definition at line 157 of file nsBidiUtils.h.

Definition at line 155 of file nsBidiUtils.h.

Definition at line 156 of file nsBidiUtils.h.

#define IBMBIDI_NUMERAL_STR   "bidi.numeral"

Definition at line 120 of file nsBidiUtils.h.

Definition at line 128 of file nsBidiUtils.h.

Definition at line 166 of file nsBidiUtils.h.

Definition at line 164 of file nsBidiUtils.h.

Definition at line 165 of file nsBidiUtils.h.

#define IBMBIDI_SUPPORTMODE_STR   "bidi.support"

Definition at line 121 of file nsBidiUtils.h.

Definition at line 124 of file nsBidiUtils.h.

Definition at line 135 of file nsBidiUtils.h.

Definition at line 136 of file nsBidiUtils.h.

#define IBMBIDI_TEXTDIRECTION_STR   "bidi.direction"

Definition at line 117 of file nsBidiUtils.h.

Definition at line 125 of file nsBidiUtils.h.

Definition at line 141 of file nsBidiUtils.h.

Definition at line 142 of file nsBidiUtils.h.

#define IBMBIDI_TEXTTYPE_STR   "bidi.texttype"

Definition at line 118 of file nsBidiUtils.h.

Definition at line 143 of file nsBidiUtils.h.

#define IS_06_CHAR (   c)    ((0x0600 <= (c)) && ((c)<= 0x06FF))

Definition at line 218 of file nsBidiUtils.h.

Value:

Definition at line 222 of file nsBidiUtils.h.

#define IS_ARABIC_CHAR (   c)    ((0x0600 <= (c)) && ((c)<= 0x06FF))

Definition at line 221 of file nsBidiUtils.h.

#define IS_ARABIC_DIGIT (   u)    ( ( (u) >= START_ARABIC_DIGITS ) && ( (u) <= END_ARABIC_DIGITS ) )

Definition at line 205 of file nsBidiUtils.h.

#define IS_ARABIC_SEPARATOR (   u)    ( ( (u) == 0x066A ) || ( (u) == 0x066B ) || ( (u) == 0x066C ) )

Definition at line 207 of file nsBidiUtils.h.

Value:
((0x202a <= (c)) && ((c)<= 0x202e) \
                                || ((c) == 0x200e) || ((c) == 0x200f))

Definition at line 224 of file nsBidiUtils.h.

Value:
( \
  ( (u) >= 0x0591 && (u) <= 0x05A1) || ( (u) >= 0x05A3 && (u) <= 0x05B9) \
    || ( (u) >= 0x05BB && (u) <= 0x05BD) || ( (u) == 0x05BF) || ( (u) == 0x05C1) \
    || ( (u) == 0x05C2) || ( (u) == 0x05C4) \
    || ( (u) >= 0x064B && (u) <= 0x0652) || ( (u) == 0x0670) \
    || ( (u) >= 0x06D7 && (u) <= 0x06E4) || ( (u) == 0x06E7) || ( (u) == 0x06E8) \
    || ( (u) >= 0x06EA && (u) <= 0x06ED) )

Definition at line 209 of file nsBidiUtils.h.

#define IS_FARSI_DIGIT (   u)    ( ( (u) >= START_FARSI_DIGITS ) && ( (u) <= END_FARSI_DIGITS ) )

Definition at line 206 of file nsBidiUtils.h.

Value:
(((0xfb50 <= (c)) && ((c)<= 0xfbFF)) \
                       || ((0xfe70 <= (c)) && ((c)<= 0xfeFC)))

Definition at line 219 of file nsBidiUtils.h.

#define IS_HEBREW_CHAR (   c)    (((0x0590 <= (c)) && ((c)<= 0x05FF)) || (((c) >= 0xfb1d) && ((c) <= 0xfb4f)))

Definition at line 217 of file nsBidiUtils.h.

#define IS_HINDI_DIGIT (   u)    ( ( (u) >= START_HINDI_DIGITS ) && ( (u) <= END_HINDI_DIGITS ) )

Definition at line 204 of file nsBidiUtils.h.

#define IS_IN_BMP_RTL_BLOCK (   c)    ((0x590 <= (c)) && ((c) <= 0x8ff))

The codepoint ranges in the following macros are based on the blocks allocated, or planned to be allocated, to right-to-left characters in the BMP (Basic Multilingual Plane) and SMP (Supplementary Multilingual Plane) according to http://unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt and http://www.unicode.org/roadmaps/.

Definition at line 236 of file nsBidiUtils.h.

#define IS_IN_SMP_RTL_BLOCK (   c)    ((0x10800 <= (c)) && ((c) <= 0x10fff))

Definition at line 239 of file nsBidiUtils.h.

Value:
(((0xfb1d <= (c)) && ((c) <= 0xfdff)) || \
                                     ((0xfe70 <= (c)) && ((c) <= 0xfefc)))

Definition at line 237 of file nsBidiUtils.h.

#define SET_BIDI_OPTION_CHARACTERSET (   bo,
  cs 
)    {(bo)=((bo) & 0xFF0FFFFF)|(((cs)& 0x0000000F)<<20);}

Definition at line 195 of file nsBidiUtils.h.

#define SET_BIDI_OPTION_CONTROLSTEXTMODE (   bo,
  cotm 
)    {(bo)=((bo) & 0xFFFFF0FF)|(((cotm)& 0x0000000F)<<8);}

Definition at line 192 of file nsBidiUtils.h.

#define SET_BIDI_OPTION_DIRECTION (   bo,
  dir 
)    {(bo)=((bo) & 0xFFFFFFF0)|(((dir)& 0x0000000F)<<0);}

Definition at line 190 of file nsBidiUtils.h.

#define SET_BIDI_OPTION_NUMERAL (   bo,
  num 
)    {(bo)=((bo) & 0xFFFF0FFF)|(((num)& 0x0000000F)<<12);}

Definition at line 193 of file nsBidiUtils.h.

#define SET_BIDI_OPTION_SUPPORT (   bo,
  sup 
)    {(bo)=((bo) & 0xFFF0FFFF)|(((sup)& 0x0000000F)<<16);}

Definition at line 194 of file nsBidiUtils.h.

#define SET_BIDI_OPTION_TEXTTYPE (   bo,
  tt 
)    {(bo)=((bo) & 0xFFFFFF0F)|(((tt)& 0x0000000F)<<4);}

Definition at line 191 of file nsBidiUtils.h.

Definition at line 200 of file nsBidiUtils.h.

#define START_FARSI_DIGITS   0x06f0

Definition at line 202 of file nsBidiUtils.h.

#define START_HINDI_DIGITS   0x0660

Definition at line 198 of file nsBidiUtils.h.

Value:

Definition at line 240 of file nsBidiUtils.h.

Value:

Definition at line 242 of file nsBidiUtils.h.


Function Documentation

nsresult ArabicShaping ( const PRUnichar aString,
PRUint32  aLen,
PRUnichar aBuf,
PRUint32 aBufLen,
PRBool  aInputLogical,
PRBool  aOutputLogical 
)

Perform Arabic shaping on a Unichar string.

Parameters:
aStringis the input string
aLenis the length of aStrong
aBufreceives the shaped output
aBuflenreceives the length of aBuf
aInputLogicalindicates that the input is in logical order
aOutputLogicalindicates that the output should be in logical order

Definition at line 275 of file nsBidiUtils.cpp.

{
  nsAutoString tempString(aString, aLen);
  if (tempString.Length() != aLen)
    return NS_ERROR_OUT_OF_MEMORY;
  PRUnichar *tempBuf = tempString.BeginWriting();
  if (aInputLogical) {
    ReverseString(tempBuf, aLen);
  }
  const PRUnichar* src = tempBuf;
  const PRUnichar* p;
  PRUnichar* dest = aBuf;
  PRUnichar formB;
  PRInt8 leftJ, thisJ, rightJ;
  PRInt8 leftNoTrJ, rightNoTrJ;
  thisJ = leftNoTrJ = eNJ;
  rightJ = GetJoiningClass(*(src));
  while(src<tempBuf+aLen-1) {
    leftJ = thisJ;

    if ((eTr != leftJ) || ((leftJ == eTr) && 
        ( ( (src-1) >= tempBuf) && !IS_ARABIC_CHAR(*(src-1)))))
      leftNoTrJ = thisJ;

    if(src-2 >= (tempBuf)){
      for(p=src-2; (p >= (tempBuf))&& (eTr == leftNoTrJ) && (IS_ARABIC_CHAR(*(p+1))) ; p--)  
        leftNoTrJ = GetJoiningClass(*(p)) ;
    }

    thisJ = rightJ;
    rightJ = rightNoTrJ = GetJoiningClass(*(src+1)) ;

    if(src+2 <= (tempBuf+aLen-1)){
      for(p=src+2; (p <= (tempBuf+aLen-1))&&(eTr == rightNoTrJ) && (IS_ARABIC_CHAR(*(src+1))); p++)
        rightNoTrJ = GetJoiningClass(*(p)) ;
    }

    formB = PresentationFormB(*src, DecideForm(leftNoTrJ, thisJ, rightNoTrJ));
    *dest++ = formB;
    src++;

  }
  if((eTr != thisJ) || 
     ((thisJ == eTr) && (((src-1)>=tempBuf) && (!IS_ARABIC_CHAR(*(src-1))))))
    leftNoTrJ = thisJ;

  if(src-2 >= (tempBuf)){
    for(p=src-2; (src-2 >= (tempBuf)) && (eTr == leftNoTrJ) && (IS_ARABIC_CHAR(*(p+1))); p--)
      leftNoTrJ = GetJoiningClass(*(p)) ;
  }

  formB = PresentationFormB(*src, DecideForm(leftNoTrJ, rightJ, eNJ));
  *dest++ = formB;
  src++;

  PRUnichar *lSrc = aBuf;
  PRUnichar *lDest = aBuf;
  while(lSrc < (dest-1)) {
    PRUnichar next = *(lSrc+1);
    if(((0xFEDF == next) || (0xFEE0 == next)) && 
       (0xFE80 == (0xFFF1 & *lSrc))) {
      PRBool done = PR_FALSE;
      PRUint16 key = ((*lSrc) << 8) | ( 0x00FF & next);
      PRUint16 i;
      for(i=0;i<8;i++) {
        if(key == gArabicLigatureMap[i]) {
          done = PR_TRUE;
          // lam and alef in the source are mapped to a lam-alef ligature in the
          // destination, so lSrc is incremented by 2 here
          *lDest++ = 0xFEF5 + i;
          lSrc+=2;
          break;
        }
      }
      if(! done)
        *lDest++ = *lSrc++; 
    } else if (0x200C == *lSrc || 0x200D == *lSrc)
    // Strip zero-width joining controls ZWJ and ZWNJ from the shaped text
      lSrc++;
    else 
      *lDest++ = *lSrc++; 

  }
  if(lSrc < dest)
    *lDest++ = *lSrc++; 

  *aBufLen = lDest - aBuf;
  NS_ASSERTION(*aBufLen <= aLen, "ArabicShaping() likely did a buffer overflow!");

  if (aOutputLogical) {
    ReverseString(aBuf, *aBufLen);
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult Conv_06_FE_WithReverse ( const nsString aSrc,
nsString aDst,
PRUint32  aDir 
)

Scan an nsString, converting characters in the 06xx range to the equivalent characters in the 0Fxx range (Arabic presentation forms), with the option to reverse the string.

Parameters:
aSrcis the input string
aDstis the output string
aDirindicates whether the string should be reversed IBMBIDI_TEXTDIRECTION_LTR: do not reverse the string IBMBIDI_TEXTDIRECTION_RTL: reverse the string

Definition at line 446 of file nsBidiUtils.cpp.

{
  PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
  PRUint32 i, beginArabic, endArabic, size;
  beginArabic = 0;
  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 = 0;
      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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult Conv_FE_06 ( const nsString aSrc,
nsString aDst 
)

Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx range.

Parameters:
aSrcis the input string
aDstis the output string

Definition at line 372 of file nsBidiUtils.cpp.

{
  PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
  PRUint32 i, size = aSrc.Length();
  aDst.Truncate();
  for (i=0;i<size;i++) { // i : Source
    if (aSrcUnichars[i] == 0x0000) 
      break; // no need to convert char after the NULL
    if (IS_FE_CHAR(aSrcUnichars[i])) {
      //ahmed for lamalf
      PRUnichar ch = (PresentationToOriginal(aSrcUnichars[i], 1));
      if(ch)
        aDst += ch;
      ch=(PresentationToOriginal(aSrcUnichars[i], 0));
      if(ch)
        aDst += ch;
      else //if it is 00, just output what we have in FExx
        aDst += aSrcUnichars[i];
    } else {
      aDst += aSrcUnichars[i]; // copy it even if it is not in FE range
    }
  }// for : loop the buffer
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx range, and also reverse the string.

Parameters:
aSrcis the input string
aDstis the output string

Definition at line 397 of file nsBidiUtils.cpp.

{
  PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
  PRBool foundArabic = PR_FALSE;
  PRUint32 i, endArabic, beginArabic, size;
  beginArabic = 0;
  size = aSrc.Length();
  aDst.Truncate();
  for (endArabic=0;endArabic<size;endArabic++) {
    if (aSrcUnichars[endArabic] == 0x0000) 
      break; // no need to convert char after the NULL

    while( (IS_FE_CHAR(aSrcUnichars[endArabic]))||
           (IS_ARABIC_CHAR(aSrcUnichars[endArabic]))||
           (IS_ARABIC_DIGIT(aSrcUnichars[endArabic]))||
           (aSrcUnichars[endArabic]==0x0020)) 
    {
      if(! foundArabic ) {
        beginArabic=endArabic;
        foundArabic= PR_TRUE;
      }
      endArabic++;
    }
    if(foundArabic) {
      endArabic--;
      for (i=endArabic; i>=beginArabic; i--) {
        if(IS_FE_CHAR(aSrcUnichars[i])) {
          //ahmed for the bug of lamalf
          aDst += PresentationToOriginal(aSrcUnichars[i], 0);
          if (PresentationToOriginal(aSrcUnichars[i], 1)) {
            // Two characters, we have to resize the buffer :(
             aDst += PresentationToOriginal(aSrcUnichars[i], 1);
          } // if expands to 2 char
        } else {
          // do we need to check the following if ?
          if((IS_ARABIC_CHAR(aSrcUnichars[i]))||
             (IS_ARABIC_DIGIT(aSrcUnichars[i]))||
             (aSrcUnichars[i]==0x0020))
            aDst += aSrcUnichars[i];
        }     
      }
    } else {
      aDst += aSrcUnichars[endArabic]; 
    }
    foundArabic=PR_FALSE;
  }// for : loop the buffer
  return NS_OK;
}

Here is the call graph for this function:

nsresult HandleNumbers ( PRUnichar aBuffer,
PRUint32  aSize,
PRUint32  aNumFlag 
)

Scan a Unichar string, converting numbers to Arabic or Hindi forms in place.

Parameters:
aBufferis the string
aSizeis the size of aBuffer
aNumFlagspecifies the conversion to perform: IBMBIDI_NUMERAL_NOMINAL: don't do any conversion IBMBIDI_NUMERAL_HINDI: convert to Hindi forms (Unicode 0660-0669) IBMBIDI_NUMERAL_ARABIC: convert to Arabic forms (Unicode 0030-0039) IBMBIDI_NUMERAL_HINDICONTEXT: convert numbers in Arabic text to Hindi, otherwise to Arabic

Definition at line 520 of file nsBidiUtils.cpp.

{
  PRUint32 i;
  // IBMBIDI_NUMERAL_NOMINAL *
  // IBMBIDI_NUMERAL_REGULAR
  // IBMBIDI_NUMERAL_HINDICONTEXT
  // IBMBIDI_NUMERAL_ARABIC
  // IBMBIDI_NUMERAL_HINDI

  switch (aNumFlag) {
    case IBMBIDI_NUMERAL_HINDI:
      for (i=0;i<aSize;i++)
        aBuffer[i] = NUM_TO_HINDI(aBuffer[i]);
      break;
    case IBMBIDI_NUMERAL_ARABIC:
      for (i=0;i<aSize;i++)
        aBuffer[i] = NUM_TO_ARABIC(aBuffer[i]);
      break;
    case IBMBIDI_NUMERAL_REGULAR:
    case IBMBIDI_NUMERAL_HINDICONTEXT:
        // for clipboard handling
        //XXX do we really want to convert numerals when copying text?
      for (i=1;i<aSize;i++) {
        if (IS_ARABIC_CHAR(aBuffer[i-1])) 
          aBuffer[i] = NUM_TO_HINDI(aBuffer[i]);
        else 
          aBuffer[i] = NUM_TO_ARABIC(aBuffer[i]);
      }
    case IBMBIDI_NUMERAL_NOMINAL:
    default:
      break;
  }
  return NS_OK;
}

Here is the caller graph for this function:

nsresult HandleNumbers ( const nsString aSrc,
nsString aDst 
)

Scan an nsString, converting numerals to Arabic or Hindi forms.

Parameters:
aSrcis the input string
aDstis the output string

Definition at line 555 of file nsBidiUtils.cpp.

{
  aDst = aSrc;
  return HandleNumbers((PRUnichar *)aDst.get(),aDst.Length(), IBMBIDI_NUMERAL_REGULAR);
}

Here is the call graph for this function: