Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions
nsOS2Uni.h File Reference
#include <os2.h>
#include <uconv.h>
#include "nsAutoBuffer.h"
#include "nsICharsetConverterManager.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  OS2Uni

Defines

#define INCL_WIN
#define CHAR_BUFFER_SIZE   1024

Typedefs

typedef nsAutoBuffer< char,
CHAR_BUFFER_SIZE
nsAutoCharBuffer
typedef nsAutoBuffer
< PRUnichar, CHAR_BUFFER_SIZE
nsAutoChar16Buffer

Enumerations

enum  ConverterRequest { eConv_Encoder, eConv_Decoder }

Functions

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)

Define Documentation

Definition at line 61 of file nsOS2Uni.h.

Definition at line 40 of file nsOS2Uni.h.


Typedef Documentation

Definition at line 63 of file nsOS2Uni.h.

Definition at line 62 of file nsOS2Uni.h.


Enumeration Type Documentation

Enumerator:
eConv_Encoder 
eConv_Decoder 

Definition at line 47 of file nsOS2Uni.h.


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:

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: