Call the Vi18nConvert function to convert the specified input buffer from the source character set to the destination character set.


Vi18nError Vi18nConvert(
   void *pContext,
   char *srcCSet,
   void *inBuf,
   int inBufBytes,
   int *convertedBytes,
   char *desCSet,
   void *outBuf,
   int outBufBytes,
   int *outputBytes,
   int unicodeEndian)




void*   The library context handle set by the Vi18nInit function.


char*   A pointer to the source character set name.


void*   A pointer to the input buffer whose contents are to be converted.


int   The length, in 8-bit bytes, of the input buffer.


int*   On completion, the actual number of 8-bit bytes converted from the input buffer for conversions between UTF8 and UNICODE; for other conversions, the value is the minimum of inBufBytes and outBufBytes.


char*   A pointer to the destination character set name.


void*   A pointer to the output buffer, which upon completion, contains the converted characters.


int   The length, in 8-bit bytes, of the output buffer.


int*   On completion, if greater than or equal to 0, the actual number of 8-bit bytes converted; if less than 0, the negation of the number of 8-bit bytes that overran the buffer.


int   The UNICODE endian format, which is one of the following values:

0 for little endian 1 for big endian


This function returns one of the following error codes:

Vi18nSuccess for success


Vi18nError_* for an error code identified in Error Codes


Vi18nFail for a non-specific error



The Vi18nConvert function converts the input buffer (inBuf argument) from the source character set (srcCSet argument) to the destination character set (desCSet argument) and places the resulting characters in the output buffer (outBuf argument). If a character in the input buffer cannot be converted, the character is replaced by an question mark (?) in the output buffer.

You can only use the Vi18nConvert function for character set conversion within the same language. For example, you can convert 8859-1 to 850, eucjp to sjis, and vice versa; however, you cannot convert GB to BIG5, and vice versa.

Character set names are case insensitive and common variations are allowed; for example, you can use 8859-1 for iso8859-1 or ISO-8859-1. (For the list of character set names, see Charset Name Mapping Table.)

You must specify an endian format in the unicodeEndian argument when either the source character set or the destination character set is UNICODE.


vgw_createToken(VgwAppSession pVSes, VgwAppStream pVStrm,
VdkToken *ppToken, VdkTokenType type,
VdkCString szName, VdkBuffer szBuffer,
VdkInt4 nSize, VdkUint4 flags)
VdkError error = VdkSuccess;
VdkUint4 n = 0;
VdkCString outBuf = NULL, outNam = NULL;
VdkToken pToken = NULL;

* convert field name/values charset here
if (szBuffer) {
if (VdkSuccess != (error =
vgw_convRtoICharset(pVSes, (VdkCString)szBuffer,
nSize>0 ? nSize : VGW_StrLen(szBuffer), &outBuf, &n)))
goto abort;
if (outBuf) {
szBuffer = (VdkBuffer)outBuf;
nSize = n;
  if (outBuf) HeapFree(outBuf);

vgw_convRtoICharset(VgwAppSession pVSes, VdkCString szIn, VdkUint4 nIn, VdkCString* ppszOut, VdkUint4* pnOut)
{ /*caller needs to call HeapFree on *ppszOut */
#define VRTY_UNICODE_CS "unicode"
VdkError error = VdkSuccess;
Vi18nError err;
int nAlloc, nConv = 0, nOut = 0, nEndian;
*ppszOut = NULL;
if (pnOut)
*pnOut = 0;
if( !pVSes->nReposCharSet ||
(VGW_StrEq(pVSes->pszReposCharSet, pVSes->pszIntCharSet)) )
return error;
if (!nIn)
return error;

/* unicode endian 'unicodeEndian', 0 for little endian, 1 for */
  /* big endian. Required when either the source or the         */
  /* destination charset is UNICODE.                            */
if (Vi18nGetCharsetEnum((char*)VRTY_UNICODE_CS) ==
#ifdef _WINDOWS
nEndian = 0;
nEndian = 1;
else if ((VdkUint2)Vi18nGetCharsetEnum(VRTY_UNICODE_CS) ==
nEndian = pVSes->nEndian;
#ifdef _WINDOWS
nEndian = 0;
nEndian = 1;
  assert(pVSes->nRtoIFactor > 0);
  nAlloc = pVSes->nRtoIFactor * (nIn + 1);
if( !(*ppszOut = (VdkCString)HeapAlloc(nAlloc)) ){
error = VdkError_OutOfMemory;
goto abort;
if (Vi18nSuccess != (err =
                 (int)  nIn,
                        nEndian))) {
error = VdkError_FatalError;
vgw_errPrint(pVSes, VdkMessageType_Error,
goto abort;
if (pnOut)
*pnOut = nOut;

return error;