Back to index

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

#include <nsUnicodeToLangBoxArabic8.h>

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

List of all members.

Public Types

enum  { kOnError_Signal, kOnError_CallBack, kOnError_Replace }

Public Member Functions

 nsUnicodeToLangBoxArabic8 ()
 Class constructor.
virtual ~nsUnicodeToLangBoxArabic8 ()
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 43 of file nsUnicodeToLangBoxArabic8.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 51 of file nsUnicodeToLangBoxArabic8.h.

{};

Definition at line 52 of file nsUnicodeToLangBoxArabic8.h.

{};

Member Function Documentation

NS_IMETHODIMP nsUnicodeToLangBoxArabic8::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 201 of file nsUnicodeToLangBoxArabic8.cpp.

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

   while (inlen < *aSrcLength) {
     PRUnichar aChar = aSrc[inlen];

     if((aChar >= 0x0660) && (aChar <=0x0669)) { /* Hindu Numerals */
       *dest++ = (char)(aChar - 0x0660 + 0xB0);
     } else if ((aChar >= 0x064B) && (aChar <= 0x0652)) {
       *dest++ = (char)(aChar - 0x64B + 0xA8);
     } else if(0x060C == aChar) {
       *dest++ = (char)0xBA;
     } else if(0x061B == aChar) {
       *dest++ = (char)0xBB;
     } else if(0x061F == aChar) {
       *dest++ = (char)0xBF;
     } else if(0x0640 == aChar) {
       *dest++ = (char)0xE0;
     } else if ((aChar>=0xFE80) && (aChar <= 0xFEF4)) {
       *dest++ = uni2lbox[aChar-0xFE80];
     } else if ((aChar >=0xFEF5) && (aChar <= 0xFEFC)) {
       PRUint8 lamAlefType = aChar - 0xFEF5;       // first map to 0-7 range,
       PRUint8 alefType = (lamAlefType & 6) >> 1;  // then the high 2 bits give us the type of alef
       PRUint8 lamType = lamAlefType & 1;          // and the low bits give us the type of lam

       *dest++ = lboxAlefs[alefType];
       *dest++ = lboxLams[lamType];
     } else if ((aChar >=0x0001) && (aChar <= 0x007F)) {
       *dest++ = (char) (aChar & 0x7F);
     } else {
       // do nothing
     }
     inlen++;
   }

    *aDestLength = dest - aDest;
    return NS_OK;
}

Implements nsICharRepresentable.

Definition at line 272 of file nsUnicodeToLangBoxArabic8.cpp.

{
   PRUnichar i;

   SET_REPRESENTABLE(aInfo, 0x060c);      
   SET_REPRESENTABLE(aInfo, 0x061b);      
   SET_REPRESENTABLE(aInfo, 0x061f);      
   for(i=0x0621;i<=0x063a;i++)
      SET_REPRESENTABLE(aInfo, i);      
   for(i=0x0640;i<=0x0652;i++)
      SET_REPRESENTABLE(aInfo, i);      
   for(i=0x0660;i<=0x0669;i++)
      SET_REPRESENTABLE(aInfo, i);      

   // Arabic Pres Form-B
   for(i=0xFE80; i < 0xFEFD;i++)
     SET_REPRESENTABLE(aInfo, i);

   // ASCII range
   for(i=0x0000; i < 0x007f;i++)
     SET_REPRESENTABLE(aInfo, i);

   return NS_OK;
}
NS_IMETHODIMP nsUnicodeToLangBoxArabic8::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 252 of file nsUnicodeToLangBoxArabic8.cpp.

{
   *aDestLength=0;
   return NS_OK;
}
NS_IMETHODIMP nsUnicodeToLangBoxArabic8::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 244 of file nsUnicodeToLangBoxArabic8.cpp.

{
  *aDestLength = 2*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 259 of file nsUnicodeToLangBoxArabic8.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 264 of file nsUnicodeToLangBoxArabic8.cpp.


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