Back to index

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

Interface for a Converter from Unicode into a Charset. More...

#include <nsIUnicodeEncoder.h>

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

List of all members.

Public Types

enum  { kOnError_Signal, kOnError_CallBack, kOnError_Replace }

Public Member Functions

NS_IMETHOD Convert (const PRUnichar *aSrc, PRInt32 *aSrcLength, char *aDest, PRInt32 *aDestLength)=0
 Converts the data from Unicode to a Charset.
NS_IMETHOD Finish (char *aDest, PRInt32 *aDestLength)=0
 Finishes the conversion.
NS_IMETHOD GetMaxLength (const PRUnichar *aSrc, PRInt32 aSrcLength, PRInt32 *aDestLength)=0
 Returns a quick estimation of the size of the buffer needed to hold the converted data.
NS_IMETHOD Reset ()=0
 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)=0
 Specify what to do when a character cannot be mapped into the dest charset.

Detailed Description

Interface for a Converter from Unicode into a Charset.

23/Nov/1998

Author:
Catalin Rotaru [CATA]

Definition at line 131 of file nsIUnicodeEncoder.h.


Member Enumeration Documentation

anonymous enum
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
  };

Member Function Documentation

NS_IMETHOD nsIUnicodeEncoder::Convert ( const PRUnichar aSrc,
PRInt32 aSrcLength,
char *  aDest,
PRInt32 aDestLength 
) [pure 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".

Implemented in nsEncoderSupport, nsUnicodeToUTF32LE, WinCEUConvAdapter, nsUnicodeToUTF32BE, nsUnicodeToTamilTTF, nsUnicodeToUTF8, nsUnicodeToTIS620, nsUnicodeToSunIndic, nsUnicodeToJamoTTF, nsUnicodeToX11Johab, nsUnicodeToTSCII, nsUnicodeToThaiTTF, nsUnicodeToLangBoxArabic16, nsUnicodeToLangBoxArabic8, and nsUnicodeToUTF16BE.

Here is the caller graph for this function:

NS_IMETHOD nsIUnicodeEncoder::Finish ( char *  aDest,
PRInt32 aDestLength 
) [pure 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

Implemented in nsEncoderSupport, nsUnicodeToUTF32LE, WinCEUConvAdapter, nsUnicodeToUTF32BE, nsUnicodeToUTF8, nsUnicodeToTIS620, nsUnicodeToSunIndic, nsUnicodeToJamoTTF, nsUnicodeToX11Johab, nsUnicodeToTSCII, nsUnicodeToLangBoxArabic16, nsUnicodeToLangBoxArabic8, and nsUnicodeToUTF16BE.

Here is the caller graph for this function:

NS_IMETHOD nsIUnicodeEncoder::GetMaxLength ( const PRUnichar aSrc,
PRInt32  aSrcLength,
PRInt32 aDestLength 
) [pure 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

Implemented in nsEncoderSupport, WinCEUConvAdapter, nsUnicodeToTamilTTF, nsUnicodeToUTF8, nsUnicodeToTIS620, nsUnicodeToSunIndic, nsUnicodeToJamoTTF, nsUnicodeToX11Johab, nsUnicodeToUTF32, nsUnicodeToTSCII, nsUnicodeToLangBoxArabic16, nsUnicodeToThaiTTF, nsUnicodeToLangBoxArabic8, and nsUnicodeToUTF16BE.

Here is the caller graph for this function:

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

Implemented in nsEncoderSupport, WinCEUConvAdapter, nsBasicUTF7Encoder, nsUnicodeToUTF8, nsUnicodeToISO2022JP, nsUnicodeToTIS620, nsUnicodeToUTF32, nsUnicodeToSunIndic, nsUnicodeToJamoTTF, nsUnicodeToX11Johab, nsUnicodeToTSCII, nsUnicodeToLangBoxArabic16, nsUnicodeToLangBoxArabic8, and nsUnicodeToUTF16BE.

Here is the caller graph for this function:

NS_IMETHOD nsIUnicodeEncoder::SetOutputErrorBehavior ( PRInt32  aBehavior,
nsIUnicharEncoder aEncoder,
PRUnichar  aChar 
) [pure virtual]

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

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

Implemented in nsEncoderSupport, WinCEUConvAdapter, nsUnicodeToTamilTTF, nsUnicodeToUTF8, nsUnicodeToTIS620, nsUnicodeToUTF32, nsUnicodeToSunIndic, nsUnicodeToJamoTTF, nsUnicodeToX11Johab, nsUnicodeToTSCII, nsUnicodeToLangBoxArabic16, nsUnicodeToLangBoxArabic8, nsUnicodeToThaiTTF, and nsUnicodeToUTF16BE.

Here is the caller graph for this function:


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