Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions
nsUnicodeToLangBoxArabic16 Class Reference

#include <nsUnicodeToLangBoxArabic16.h>

Inheritance diagram for nsUnicodeToLangBoxArabic16:
Inheritance graph
[legend]
Collaboration diagram for nsUnicodeToLangBoxArabic16:
Collaboration graph
[legend]

List of all members.

Public Types

enum  { kOnError_Signal, kOnError_CallBack, kOnError_Replace }

Public Member Functions

 nsUnicodeToLangBoxArabic16 ()
 Class constructor.
virtual ~nsUnicodeToLangBoxArabic16 ()
NS_IMETHOD Convert (const PRUnichar *aSrc, PRInt32 *aSrcLength, char *aDest, PRInt32 *aDestLength)
 Converts the data from Unicode to a Charset.
NS_IMETHOD Finish (char *aDest, PRInt32 *aDestLength)
 Finishes the conversion.
NS_IMETHOD GetMaxLength (const PRUnichar *aSrc, PRInt32 aSrcLength, PRInt32 *aDestLength)
 Returns a quick estimation of the size of the buffer needed to hold the converted data.
NS_IMETHOD Reset ()
 Resets the charset converter so it may be recycled for a completely different and urelated buffer of data.
NS_IMETHOD SetOutputErrorBehavior (PRInt32 aBehavior, nsIUnicharEncoder *aEncoder, PRUnichar aChar)
 Specify what to do when a character cannot be mapped into the dest charset.
NS_IMETHOD FillInfo (PRUint32 *aInfo)

Detailed Description

Definition at line 44 of file nsUnicodeToLangBoxArabic16.h.


Member Enumeration Documentation

anonymous enum [inherited]
Enumerator:
kOnError_Signal 
kOnError_CallBack 
kOnError_Replace 

Definition at line 136 of file nsIUnicodeEncoder.h.

       {
    kOnError_Signal,        // on an error, stop and signal
    kOnError_CallBack,      // on an error, call the error handler
    kOnError_Replace       // on an error, replace with a different character
  };

Constructor & Destructor Documentation

Class constructor.

Definition at line 52 of file nsUnicodeToLangBoxArabic16.h.

{};

Definition at line 53 of file nsUnicodeToLangBoxArabic16.h.

{};

Member Function Documentation

NS_IMETHODIMP nsUnicodeToLangBoxArabic16::Convert ( const PRUnichar aSrc,
PRInt32 aSrcLength,
char *  aDest,
PRInt32 aDestLength 
) [virtual]

Converts the data from Unicode to a Charset.

About the byte ordering:

  • The input stream is Unicode, having the byte order which is internal for the machine on which the converter is running on.
  • For output, if the converter cares (that depends of the charset, for example a singlebyte will ignore the byte ordering) it should assume network order. If necessary and requested, we can add a method SetOutputByteOrder() so that the reverse order can be used, too. That method would have as default the assumed network order.

Unless there is not enough output space, this method must consume all the available input data! We don't have partial input for the Unicode charset. And for the last converted char, even if there is not enought output space, a partial ouput must be done until all available space will be used. The rest of the output should be buffered until more space becomes available. But this is not also true about the error handling method!!! So be very, very careful...

Parameters:
aSrc[IN] the source data buffer
aSrcLength[IN/OUT] the length of source data buffer; after conversion will contain the number of Unicode characters read
aDest[OUT] the destination data buffer
aDestLength[IN/OUT] the length of the destination data buffer; after conversion will contain the number of bytes written
Returns:
NS_OK_UENC_MOREOUTPUT if only a partial conversion was done; more output space is needed to continue NS_ERROR_UENC_NOMAPPING if character without mapping was encountered and the behavior was set to "signal".

Implements nsIUnicodeEncoder.

Definition at line 192 of file nsUnicodeToLangBoxArabic16.cpp.

{
   char* dest = aDest;
   PRInt32 inlen = 0;

   while (inlen < *aSrcLength) {
     PRUnichar aChar = aSrc[inlen];
     
     if (((aChar >= 0x0020) && (aChar <= 0x0027)) ||
          (aChar == 0x2A) ||
          (aChar == 0x2B) ||
         ((aChar >= 0x002D) && (aChar <= 0x002F)) ||
          (aChar == 0x003A) ||
         ((aChar >= 0x003C) && (aChar <= 0x003E)) ||
          (aChar == 0x40) ||
          (aChar == 0x5C) ||
          (aChar == 0x5E) ||
          (aChar == 0x5F) ||
          (aChar == 0x7C) ||
          (aChar == 0x7E)) {
       *dest++ = (char) aChar;
       // ISO-8859-6-16 swaps symmetric characters internally, but we have
       // already swapped them where necessary during Bidi reordering, so we
       // must swap them back here.
     } else if (0x0028 == aChar) {
       *dest++ = 0x29;
     } else if (0x0029 == aChar) {
       *dest++ = 0x28;
     } else if (0x005B == aChar) {
       *dest++ = 0x5D;
     } else if (0x005D == aChar) {
       *dest++ = 0x5B;
     } else if (0x007B == aChar) {
       *dest++ = 0x7D;
     } else if (0x007D == aChar) {
       *dest++ = 0x7B;
     } else if (0x060C == aChar) {
       // ARABIC COMMA
       *dest++ = 0x2C;
     } else if (0x061B == aChar) {
       // ARABIC SEMICOLON
       *dest++ = 0x3B;
     } else if (0x061F == aChar) {
       // ARABIC QUESTION MARK
       *dest++ = 0x3F;
     } else if (0x0640 == aChar) {
       // ARABIC TATWEEL
       *dest++ = 0x60;
     } else if ((aChar >= 0x0660) && (aChar <=0x0669)) {
       // ARABIC-INDIC DIGITS
       *dest++ = (char)(aChar - 0x0660 + 0x30);
     } else if ((aChar>=0xFE70) && (aChar <= 0xFEFC)) {
       // ARABIC PRESENTATION FORMS
       *dest++ = uni2lbox[aChar-0xFE70];
     } else {
       // do nothing
     }
     inlen++;
   }

    *aDestLength = dest - aDest;
    return NS_OK;
}

Implements nsICharRepresentable.

Definition at line 286 of file nsUnicodeToLangBoxArabic16.cpp.

{
   PRUnichar i;

   /* Start off by marking the whole ASCII range as unrepresentable. If we
    * don't do this we will try to use an ISO-8859-6.16 font for ASCII text
    * embedded in Arabic content, and it will not be rendered correctly.
    * See discussion in bug 172491
    */
   for(i=0x0000; i <= 0x007F; i++)
     CLEAR_REPRESENTABLE(aInfo, i);

   // Mark the few exceptions as representable.
   for(i=0x0020; i <= 0x002B; i++)
     SET_REPRESENTABLE(aInfo, i);
   for(i=0x002D; i <= 0x002F; i++)
     SET_REPRESENTABLE(aInfo, i);
   SET_REPRESENTABLE(aInfo, 0x003A);
   for(i=0x003C; i <= 0x003E; i++)
     SET_REPRESENTABLE(aInfo, i);
   SET_REPRESENTABLE(aInfo, 0x0040);
   for(i=0x005B; i <= 0x005F; i++)
     SET_REPRESENTABLE(aInfo, i);
   for(i=0x007B; i <= 0x007E;i++)
     SET_REPRESENTABLE(aInfo, i);

   // Arabic punctuation and numerals
   SET_REPRESENTABLE(aInfo, 0x060c);
   SET_REPRESENTABLE(aInfo, 0x061b);
   SET_REPRESENTABLE(aInfo, 0x061f);
   SET_REPRESENTABLE(aInfo, 0x0640);
   for(i=0x0660; i<=0x0669; i++)
      SET_REPRESENTABLE(aInfo, i);

   // Arabic Pres Form-B
   for(i=0xFE70; i <= 0xFE72; i++)
     SET_REPRESENTABLE(aInfo, i);
   SET_REPRESENTABLE(aInfo, 0xFE74);
   for(i=0xFE76; i <= 0xFEFC; i++)
     SET_REPRESENTABLE(aInfo, i);

   return NS_OK;
}
NS_IMETHODIMP nsUnicodeToLangBoxArabic16::Finish ( char *  aDest,
PRInt32 aDestLength 
) [virtual]

Finishes the conversion.

The converter has the possibility to write some extra data and flush its final state.

Parameters:
aDest[OUT] the destination data buffer
aDestLength[IN/OUT] the length of destination data buffer; after conversion it will contain the number of bytes written
Returns:
NS_OK_UENC_MOREOUTPUT if only a partial conversion was done; more output space is needed to continue

Implements nsIUnicodeEncoder.

Definition at line 266 of file nsUnicodeToLangBoxArabic16.cpp.

{
   *aDestLength=0;
   return NS_OK;
}
NS_IMETHODIMP nsUnicodeToLangBoxArabic16::GetMaxLength ( const PRUnichar aSrc,
PRInt32  aSrcLength,
PRInt32 aDestLength 
) [virtual]

Returns a quick estimation of the size of the buffer needed to hold the converted data.

Remember: this estimation is >= with the actual size of the buffer needed. It will be computed for the "worst case"

Parameters:
aSrc[IN] the source data buffer
aSrcLength[IN] the length of source data buffer
aDestLength[OUT] the needed size of the destination buffer
Returns:
NS_OK_UENC_EXACTLENGTH if an exact length was computed NS_OK if all we have is an approximation

Implements nsIUnicodeEncoder.

Definition at line 258 of file nsUnicodeToLangBoxArabic16.cpp.

{
  *aDestLength = aSrcLength;
  return NS_OK;
}

Resets the charset converter so it may be recycled for a completely different and urelated buffer of data.

Implements nsIUnicodeEncoder.

Definition at line 273 of file nsUnicodeToLangBoxArabic16.cpp.

{
   return NS_OK;
}

Specify what to do when a character cannot be mapped into the dest charset.

Parameters:
aOrder[IN] the behavior; taken from the enum

Implements nsIUnicodeEncoder.

Definition at line 278 of file nsUnicodeToLangBoxArabic16.cpp.


The documentation for this class was generated from the following files: