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.
For the last converted char, even if there is not enough 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...
|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 |
- NS_OK_UENC_MOREOUTPUT if only a partial conversion was done; more output space is needed to continue NS_OK_UENC_MOREINPUT if only a partial conversion was done; more input is needed to continue. This can occur when the last UTF-16 code point in the input is the first of a surrogate pair. NS_ERROR_UENC_NOMAPPING if character without mapping was encountered and the behavior was set to "signal".
Implemented in nsUnicodeToUTF8, nsUnicodeToUTF32BE, nsUnicodeToUTF32LE, and nsEncoderSupport.
Referenced by nsTestUConv::ConvertEncode().