PRUint32 loop = aLen; PRUint32 z; for (z=0; z<=aLen; z++) { temp.SetCharAt((PRUnichar)aStr[loop], z); loop--; }
PRInt32 len = newBuffer.Length(); PRUint32 z = 0; nsAutoString temp; temp.SetLength(len); while (--len >= 0) temp.SetCharAt(newBuffer.CharAt(len), z++); newBuffer = temp;
nsFormSubmission::UnicodeToNewBytes(const PRUnichar* aStr, PRUint32 aLen,                                    nsISaveAsCharset* aEncoder){  nsresult rv = NS_OK;  PRUint8 ctrlsModAtSubmit = GET_BIDI_OPTION_CONTROLSTEXTMODE(mBidiOptions);  PRUint8 textDirAtSubmit = GET_BIDI_OPTION_DIRECTION(mBidiOptions);  //ahmed 15-1  nsAutoString temp;  nsAutoString newBuffer;  //This condition handle the RTL,LTR for a logical file  if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_VISUAL     && mCharset.Equals(NS_LITERAL_CSTRING("windows-1256"),                        nsCaseInsensitiveCStringComparator())) {    Conv_06_FE_WithReverse(nsString(aStr),                           newBuffer,                           textDirAtSubmit);    aStr = newBuffer.get();    aLen=newBuffer.Length();  }  else if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_LOGICAL          && mCharset.Equals(NS_LITERAL_CSTRING("IBM864"),                             nsCaseInsensitiveCStringComparator())) {    //For 864 file, When it is logical, if LTR then only convert    //If RTL will mak a reverse for the buffer    Conv_FE_06(nsString(aStr), newBuffer);    aStr = newBuffer.get();    temp = newBuffer;    aLen=newBuffer.Length();    if (textDirAtSubmit == 2) { //RTL    //Now we need to reverse the Buffer, it is by searching the buffer      PRUint32 loop = aLen;      PRUint32 z;      for (z=0; z<=aLen; z++) {        temp.SetCharAt((PRUnichar)aStr[loop], z);        loop--;      }    }    aStr = temp.get();  }  else if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_VISUAL          && mCharset.Equals(NS_LITERAL_CSTRING("IBM864"),                             nsCaseInsensitiveCStringComparator())                  && textDirAtSubmit == IBMBIDI_TEXTDIRECTION_RTL) {    Conv_FE_06(nsString(aStr), newBuffer);    aStr = newBuffer.get();    temp = newBuffer;    aLen=newBuffer.Length();    //Now we need to reverse the Buffer, it is by searching the buffer    PRUint32 loop = aLen;    PRUint32 z;    for (z=0; z<=aLen; z++) {      temp.SetCharAt((PRUnichar)aStr[loop], z);      loop--;    }    aStr = temp.get();  }    char* res = nsnull;  if(aStr && aStr[0]) {    rv = aEncoder->Convert(aStr, &res);    NS_ASSERTION(NS_SUCCEEDED(rv), "conversion failed");  }   if(! res)    res = nsCRT::strdup("");  return res;}