Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsOS2Uni.cpp File Reference
#include "nsOS2Uni.h"
#include "nsIServiceManager.h"
#include "nsIPlatformCharset.h"
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  ConverterInfo

Defines

#define eCONVERTER_COUNT   17

Functions

static NS_DEFINE_CID (kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID)
nsresult WideCharToMultiByte (int aCodePage, const PRUnichar *aSrc, PRInt32 aSrcLength, nsAutoCharBuffer &aResult, PRInt32 &aResultLength)
nsresult MultiByteToWideChar (int aCodePage, const char *aSrc, PRInt32 aSrcLength, nsAutoChar16Buffer &aResult, PRInt32 &aResultLength)

Variables

ConverterInfo gConverterInfo [eCONVERTER_COUNT]

Class Documentation

struct ConverterInfo

Definition at line 48 of file nsOS2Uni.cpp.

Collaboration diagram for ConverterInfo:
Class Members
PRUint16 mCodePage
char * mConvName
nsIUnicodeDecoder * mDecoder
nsIUnicodeEncoder * mEncoder

Define Documentation

Definition at line 56 of file nsOS2Uni.cpp.


Function Documentation

nsresult MultiByteToWideChar ( int  aCodePage,
const char *  aSrc,
PRInt32  aSrcLength,
nsAutoChar16Buffer aResult,
PRInt32 aResultLength 
)

Definition at line 165 of file nsOS2Uni.cpp.

{
  nsresult rv;
  nsISupports* sup = OS2Uni::GetUconvObject(aCodePage, eConv_Decoder);
  nsCOMPtr<nsIUnicodeDecoder> uco = do_QueryInterface(sup);

  if (NS_FAILED(uco->GetMaxLength(aSrc, aSrcLength, &aResultLength))) {
    return NS_ERROR_UNEXPECTED;
  }
  if (!aResult.EnsureElemCapacity(aResultLength + 1))
    return NS_ERROR_OUT_OF_MEMORY;
  PRUnichar* str = aResult.get();

  rv = uco->Convert(aSrc, &aSrcLength, str, &aResultLength);
  aResult.get()[aResultLength] = '\0';
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kCharsetConverterManagerCID  ,
NS_ICHARSETCONVERTERMANAGER_CID   
) [static]
nsresult WideCharToMultiByte ( int  aCodePage,
const PRUnichar aSrc,
PRInt32  aSrcLength,
nsAutoCharBuffer aResult,
PRInt32 aResultLength 
)

Definition at line 141 of file nsOS2Uni.cpp.

{
  nsresult rv;
  nsISupports* sup = OS2Uni::GetUconvObject(aCodePage, eConv_Encoder);
  nsCOMPtr<nsIUnicodeEncoder> uco = do_QueryInterface(sup);

  if (NS_FAILED(uco->GetMaxLength(aSrc, aSrcLength, &aResultLength))) {
    return NS_ERROR_UNEXPECTED;
  }
  if (!aResult.EnsureElemCapacity(aResultLength + 1))
    return NS_ERROR_OUT_OF_MEMORY;
  char* str = aResult.get();

  rv = uco->Convert(aSrc, &aSrcLength, str, &aResultLength);
  aResult.get()[aResultLength] = '\0';
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
{
  { 0,    "",              nsnull,  nsnull },
  { 1252, "windows-1252",  nsnull,  nsnull },
  { 1208, "UTF-8",         nsnull,  nsnull },
  { 1250, "windows-1250",  nsnull,  nsnull },
  { 1251, "windows-1251",  nsnull,  nsnull },
  { 813,  "ISO-8859-7",    nsnull,  nsnull },
  { 1254, "windows-1254",  nsnull,  nsnull },
  { 864,  "IBM864",        nsnull,  nsnull },
  { 1257, "windows-1257",  nsnull,  nsnull },
  { 874,  "windows-874",   nsnull,  nsnull },
  { 932,  "Shift_JIS",     nsnull,  nsnull },
  { 943,  "Shift_JIS",     nsnull,  nsnull },
  { 1381, "GB2312",        nsnull,  nsnull },
  { 1386, "GB2312",        nsnull,  nsnull },
  { 949,  "x-windows-949", nsnull,  nsnull },
  { 950,  "Big5",          nsnull,  nsnull },
  { 1361, "x-johab",       nsnull,  nsnull }
}

Definition at line 57 of file nsOS2Uni.cpp.