Back to index

im-sdk  12.3.91
Defines | Functions | Variables
iiimpConv.c File Reference
#include <iconv.h>
#include <locale.h>
#include <langinfo.h>
#include <strings.h>
#include <errno.h>
#include "iiimpIM.h"
#include "xiiimp.h"
#include "iiimpReq.h"
#include "iiimpColor.h"
#include "iiimpConv.h"

Go to the source code of this file.

Defines

#define USE_ICONV
#define UTF16_STRLEN   4096
#define MAXINT   (~((unsigned int)1 << (8 * sizeof(int)) - 1))

Functions

static int ConvertToUTF16 (char *current_encoding, char *from_buf, size_t from_left, char **to_buf, size_t *to_left)
int IMConvertFromUTF8ToUTF16 (char *from_buf, size_t from_left, char **to_buf, size_t *to_left)
int IMConvertFromUTF8 (char *from_buf, size_t from_left, char **to_buf, size_t *to_left)
int IMConvertToUTF8 (char *from_buf, size_t from_left, char **to_buf, size_t *to_left)
int IIimpConvertToUTF16 (char *from_buf, size_t from_left, char **to_buf, size_t *to_left)
int IIimpConvertFromUTF16 (const char *from_buf, size_t from_left, char **to_buf, size_t *to_left)
static IIIMF_status UTF16ToString (int len, const IIIMP_card16 *ucstr, Bool useUnicode, char **pstr)
IIIMF_status IIimpUTF16ToString (const IIIMP_card16 *ucstr, Bool useUnicode, char **pstr)
IIIMF_status IIimpConvertToString (IIIMCF_text text, Bool useUnicode, char **pstr)
IIIMF_status IIimpConvertToXIMText (IIIMCF_text text, XIMText *pxt, IMFeedbackList **ppfeedbacks, Bool useUnicode)
int IIimpWcstoMbs (XimCommon im, wchar_t *from, int from_len, char *to, int to_len, Status *state)
int IIimpMbstoWcs (XimCommon im, char *from, int from_len, wchar_t *to, int to_len, Status *state)

Variables

static iconv_t i_conv1 = NULL
static iconv_t i_conv2 = NULL
static Bool skip_native_to_utf8_conv = False
static iconv_t i_conv1_FromUTF16 = NULL
static iconv_t i_conv2_FromUTF16 = NULL
static iconv_t i_conv_ToUTF8 = NULL

Define Documentation

#define MAXINT   (~((unsigned int)1 << (8 * sizeof(int)) - 1))

Definition at line 709 of file iiimpConv.c.

#define USE_ICONV

Definition at line 47 of file iiimpConv.c.

#define UTF16_STRLEN   4096

Definition at line 67 of file iiimpConv.c.


Function Documentation

static int ConvertToUTF16 ( char *  current_encoding,
char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
) [static]

Definition at line 125 of file iiimpConv.c.

{
    size_t src_len, dst_len;
    char *src, *dst;
#ifndef USE_CSCONV
    const char *ip;
    size_t ileft;
    char *op;
    size_t oleft;
    char buffer[UTF16_STRLEN];            /* Fix me! */
#endif /* !USE_CSCONV */
    const size_t buf_len = UTF16_STRLEN;
    size_t ret = 0;
#ifdef USE_CSCONV
    static csconv_t csconv_cd = NULL;

#endif

    if (current_encoding == NULL) return 0;

#ifdef USE_CSCONV

    do {
       if (((void *)(-1) == csc_handle) ||
           ((csconv_t)(-1) == csconv_cd)) {
           continue;
       }
       if (NULL == csc_handle) {
           dlopen_csconv();
           if ((void *)(-1) == csc_handle) {
              continue;
           }
       }
       if (NULL == csconv_cd) {

           csconv_cd = (csc_open_locale)(current_encoding,
                                     "UTF-16", "MultiByte");
      
           if ((csconv_t)(-1) == csconv_cd) {
              continue;
           }
       }

       dst = *((char **)to_buf);

       ret = csc_conv(csconv_cd,
                     (const char **)&from_buf, &from_left,
                     &dst, to_left);
       return ret;
    } while (0);
#endif

#ifdef USE_ICONV
    if (i_conv1 == (iconv_t)-1 || i_conv2 == (iconv_t)-1){
       goto done;
    }

    if (i_conv1 == NULL && !skip_native_to_utf8_conv) {
       if (!strcmp(current_encoding, "UTF-8")) {
           skip_native_to_utf8_conv = True;
       } else {
           if ((i_conv1 = iconv_open("UTF-8", current_encoding))
              == (iconv_t)-1) {
              /* fallback */
              current_encoding = "646";
              if ((i_conv1 = iconv_open("UTF-8", current_encoding))
                  == (iconv_t)-1)
                  goto done;
           }
       }
    }

    if (i_conv2 == NULL){
       if ((i_conv2 = iconv_open("UTF-16",
                              "UTF-8")) == (iconv_t)-1)
           goto done;
    }

    if (!skip_native_to_utf8_conv) {
       ip = (const char *)from_buf;
       ileft = from_left;

       op = *((char **)to_buf);
       oleft = *to_left;

       while ((0 < ileft) && (0 < oleft)) {
           dst = buffer;
           dst_len = buf_len;
           ret = iconv(i_conv1, &ip, &ileft, (char**)&dst, &dst_len);
           if ((ret != 0) && (E2BIG != errno)) {
              goto done;
           }

           src = buffer;
           src_len = buf_len - dst_len;

           ret = iconv(i_conv2, (const char**)&src, &src_len, &op, &oleft);
           if (ret != 0) goto done;
       }

       dst_len = oleft;

    } else {
       src = from_buf;
       src_len = from_left;
       dst = *to_buf;
       dst_len = *to_left;

       ret = iconv(i_conv2, (const char**)&src, &src_len, (char**)&dst, &dst_len);
    }

    if (0xFEFF == **((CARD16 **)to_buf)) {
       memmove(*to_buf, *to_buf + 2, *to_left - dst_len - 2);
       *to_left = (dst_len + 2);
    } else {
       *to_left = dst_len;
    }
done:
#endif /* USE_ICONV */
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IIimpConvertFromUTF16 ( const char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
)

Definition at line 418 of file iiimpConv.c.

{
    size_t src_len, dst_len;
    char *src, *dst;
#ifndef USE_CSCONV
    const char *ip;
    size_t ileft;
    char *op;
    size_t oleft;
    char buffer[UTF16_STRLEN];     /* Fix me! */
#endif /* !USE_CSCONV */
    const size_t buf_len = UTF16_STRLEN;
    size_t ret = 0;

#ifdef USE_CSCONV
    static csconv_t csconv_cd = NULL;
#endif

#ifdef USE_CSCONV
    if (current_locale == NULL){
       current_locale = (char*)strdup(setlocale(LC_CTYPE, NULL));
    }
    do {
       if (((void *)(-1) == csc_handle) ||
           ((csconv_t)(-1) == csconv_cd)) {
           continue;
       }
       if (NULL == csc_handle) {
           dlopen_csconv();
           if ((void *)(-1) == csc_handle) {
              continue;
           }
       }
       if (NULL == csconv_cd) {

           csconv_cd = (csc_open_locale)(current_locale, "MultiByte", "UTF-16");
      
           if ((csconv_t)(-1) == csconv_cd) {
              continue;
           }
       }

       dst = *((char **)to_buf);

       ret = csc_conv(csconv_cd,
                     &from_buf, &from_left, &dst, to_left);
       return ret;
    } while (0);
#endif

#ifdef USE_ICONV
    if (i_conv1_FromUTF16 == (iconv_t)-1 ||
       i_conv2_FromUTF16 == (iconv_t)-1) {
       goto done;
    }

    if (i_conv2_FromUTF16 == NULL && !skip_native_to_utf8_conv) {
       char *encoding = nl_langinfo(CODESET);
       if (!strcmp(encoding, "UTF-8")) {
           skip_native_to_utf8_conv = True;
       } else {
           if ((i_conv2_FromUTF16 = iconv_open(encoding, "UTF-8"))
              == (iconv_t) - 1) {
              /* fallback */
              encoding = "646";
              if ((i_conv2_FromUTF16 = iconv_open(encoding, "UTF-8"))
                  == (iconv_t) - 1)
                  goto done;
           }
       }
    }
    if (i_conv1_FromUTF16 == NULL) {
       if ((i_conv1_FromUTF16 = iconv_open("UTF-8", "UTF-16"))
           == (iconv_t) - 1) {
           goto done;
       }
    }

    if (skip_native_to_utf8_conv) {
       src = from_buf;
       src_len = from_left; /* don't stop at '\0' in case of ascii */
       dst = *((char **) to_buf);

       ret = iconv(i_conv1_FromUTF16, (const char**)&src, &src_len,
                  (char**)&dst, to_left);
    } else {
       ip = (const char *)from_buf;
       ileft = from_left;

       op = *((char **)to_buf);
       oleft = *to_left;

       while ((0 < ileft) && (0 < oleft)) {
           dst = buffer;
           dst_len = buf_len;
           ret = iconv(i_conv1_FromUTF16, &ip, &ileft, (char**)&dst, &dst_len);
           if ((ret != 0) && (E2BIG != errno)) {
              goto done;
           }

           src = buffer;
           src_len = buf_len - dst_len;

           ret = iconv(i_conv2_FromUTF16, (const char**)&src, &src_len,
                     &op, &oleft);
           if (ret != 0) goto done;
       }

       *to_left = oleft;
    }
done:
#endif /* USE_ICONV */
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status IIimpConvertToString ( IIIMCF_text  text,
Bool  useUnicode,
char **  pstr 
)

Definition at line 594 of file iiimpConv.c.

{
    IIIMF_status st;
    int len;
    const IIIMP_card16 *ucstr;

    st = iiimcf_get_text_length(text, &len); 
    if (st != IIIMF_STATUS_SUCCESS) return st;
    if (len == 0) {
       *pstr = NULL;
       return IIIMF_STATUS_SUCCESS;
    }
    st = iiimcf_get_text_utf16string(text, &ucstr);
    if (st != IIIMF_STATUS_SUCCESS) return st;

    return UTF16ToString(len, ucstr, useUnicode, pstr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IIimpConvertToUTF16 ( char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
)

Definition at line 393 of file iiimpConv.c.

{
#ifdef USE_CSCONV
    if (current_locale == NULL){
       current_locale = (char*)strdup(setlocale(LC_CTYPE, NULL));
    }
    return ConvertToUTF16(current_locale,
                       from_buf, from_left,
                       to_buf, to_left);
#else
    char *encoding = nl_langinfo(CODESET);
    return ConvertToUTF16(encoding,
                       from_buf, from_left,
                       to_buf, to_left);
#endif
}

Here is the caller graph for this function:

IIIMF_status IIimpConvertToXIMText ( IIIMCF_text  text,
XIMText *  pxt,
IMFeedbackList **  ppfeedbacks,
Bool  useUnicode 
)

Definition at line 617 of file iiimpConv.c.

{
    IIIMF_status st;
    IIIMP_card16 ch;
    const IIIMP_card32 *pids, *pfbs;
    XIMFeedback *ximfb = NULL, *ximfb_top = NULL;
    IMFeedbackList *pfl = NULL, *pfl2 = NULL;
    IMFeedback *pfb, *pfb2;
    int i, len;
    int j, nfb;
    Bool has_feedback = False;

    memset(pxt, 0, sizeof(*pxt));
    st = iiimcf_get_text_length(text, &len); 
    if (st != IIIMF_STATUS_SUCCESS) goto error;
    if (len == 0) {
       if (ppfeedbacks) *ppfeedbacks = NULL;
       return IIIMF_STATUS_SUCCESS;
    }

    pfl = pfl2 = NULL;
    ximfb_top = ximfb = (XIMFeedback*) Xmalloc(sizeof(*ximfb) * len);
    memset(ximfb, 0, sizeof(*ximfb) * len);
    if (!ximfb) goto memory_error;
    if (ppfeedbacks) {
       pfl = pfl2 = (IMFeedbackList*) Xmalloc(sizeof(*pfl) * len);
       if (!pfl) goto memory_error;
       memset(pfl, 0, sizeof(*pfl) * len);
    }
    pxt->feedback = ximfb;
    pxt->length = len;

    for (i = 0; i < len; i++, ximfb++) {
       st = iiimcf_get_char_with_feedback(text, i, &ch, &nfb, &pids, &pfbs);
       if (st != IIIMF_STATUS_SUCCESS) goto error;
       if (pfl) {
           int count_nfb = 0;
           pfb = pfb2 = (IMFeedback*) Xmalloc(sizeof(IMFeedback) * nfb);
           if (!pfb) goto memory_error;
           for (j = 0; j < nfb; j++, pids++, pfbs++) {
              if (*pids == 0)
                *ximfb = *pfbs;
              else {
                has_feedback = True;
                pfb2->type = *pids;
                pfb2->value = *pfbs;
                pfb2++;
                count_nfb++;
              }
           }
           pfl2->count_feedbacks = count_nfb;
           pfl2->feedbacks = pfb;
           pfl2++;
       } else {
           for (j = 0; j < nfb; j++, pids++) {
              if (*pids == 0) {
                  *ximfb = pfbs[j];
                  break;
              }
           }
       }
    }

    st = IIimpConvertToString(text, useUnicode, &pxt->string.multi_byte);
    if (st != IIIMF_STATUS_SUCCESS) goto error;

    if (ppfeedbacks) {
      if (!has_feedback) {
       FreeFeedbackList(pfl, len);
        pfl = NULL;
      }
      *ppfeedbacks = pfl;
    }

    return IIIMF_STATUS_SUCCESS;

memory_error:
    st = IIIMF_STATUS_MALLOC;
error:
    if (ximfb_top) free(ximfb_top);
    if (pfl) FreeFeedbackList(pfl, len);
    if (pxt->string.multi_byte) free(pxt->string.multi_byte);

    return st;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IIimpMbstoWcs ( XimCommon  im,
char *  from,
int  from_len,
wchar_t *  to,
int  to_len,
Status *  state 
)

Definition at line 806 of file iiimpConv.c.

                                                     {
  XlcConv conv = im->mtow_conv;
  int from_left;
  int to_left;
  int from_savelen;
  int to_savelen;
  int from_cnvlen;
  int to_cnvlen;
  char *from_buf;
  wchar_t *to_buf, *tmp_buf;
  Status tmp_state;

  if (!state)
    state = &tmp_state;

  /* Change to_len as to_len * sizeof(wchar_t)  - byte length */
  to_len = to_len * sizeof(wchar_t); 
  if (!conv || !from || !from_len) {
    *state = XLookupNone;
    return 0;
  }

  if (to && to_len) {
    from_left = from_len;
    to_left = to_len;
    from_cnvlen = 0;
    to_cnvlen = 0;
    for (;;) {
      from_savelen = from_left;
      to_savelen = to_left;
      from_buf = &from[from_cnvlen];
      to_buf = &to[to_cnvlen];
      if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                    (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
       *state = XLookupNone;
       return 0;
      }
      from_cnvlen += (from_savelen - from_left);
      to_cnvlen += (to_savelen - to_left);
      if (from_left == 0) {
       if (to_cnvlen > 0) {
         *state = XLookupChars;
       } else {
         *state = XLookupNone;
       }
       return to_cnvlen;
      }
      if (to_left == 0)
       break;
      /* Overflow : the to_left length is so small that it cannot
         accomodate the first mb character in the next conversion block */
      if (to_left < sizeof(wchar_t)) {
         break;
      }
    }
  }
  from_left = from_len;
  from_cnvlen = 0;
  to_cnvlen = 0;
  /* BugId : 4253988. In case the from_buf is bigger than the to_buffer,
       we need to return the required buffer size and status as XBufferOverflow.
       We create a tmp buffer equals 8 times the from_len and do conversion.
  */
  to_left = from_len ;
  tmp_buf = (wchar_t *)malloc(to_left * sizeof(wchar_t));
  for (;;) {
    from_savelen = from_left;
    from_buf = &from[from_cnvlen];
    to_savelen = to_left;
    to_buf = &tmp_buf[to_cnvlen];
    from_buf = &from[from_cnvlen];
    if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                  (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
      *state = XLookupNone;
      return 0;
    }
    from_cnvlen += (from_savelen - from_left);
    to_cnvlen += (to_savelen - to_left);
    if (from_left == 0) {
      if (to_cnvlen > 0)
       *state = XBufferOverflow;
      else
       *state = XLookupNone;
      break;
    }
  }
  free(tmp_buf);
  return to_cnvlen;
}

Here is the call graph for this function:

Here is the caller graph for this function:

IIIMF_status IIimpUTF16ToString ( const IIIMP_card16 ucstr,
Bool  useUnicode,
char **  pstr 
)

Definition at line 581 of file iiimpConv.c.

{
    int len;

    for (len = 0; ucstr[len]; len++);
    return UTF16ToString(len, ucstr, useUnicode, pstr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IIimpWcstoMbs ( XimCommon  im,
wchar_t *  from,
int  from_len,
char *  to,
int  to_len,
Status *  state 
)

Definition at line 713 of file iiimpConv.c.

                                                  {
  XlcConv conv = im->wtom_conv;
  int from_left;
  int to_left;
  int from_savelen;
  int to_savelen;
  int from_cnvlen;
  int to_cnvlen;
  wchar_t *from_buf;
  char *to_buf, *tmp_buf;
  Status tmp_state;

  if (!state)
    state = &tmp_state;

  if (!conv || !from || !from_len) {
    *state = XLookupNone;
    return 0;
  }

  if (*from == (wchar_t)0) {
    to[0] = (char)0;
    return 0;
  }
  if (to && to_len) {
    from_left = from_len;
    to_left = to_len;
    from_cnvlen = 0;
    to_cnvlen = 0;
    for (;;) {
      from_savelen = from_left;
      to_savelen = to_left;
      from_buf = &from[from_cnvlen];
      to_buf = &to[to_cnvlen];
      if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                    (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
       *state = XLookupNone;
       return 0;
      }
      from_cnvlen += (from_savelen - from_left);
      to_cnvlen += (to_savelen - to_left);
      if (from_left == 0) {
       if (to_cnvlen > 0) {
         *state = XLookupChars;
       } else {
         *state = XLookupNone;
       }
       return to_cnvlen;
      }
      if (to_left == 0)
       break;
      /* Overflow : the to_left length is so small that it cannot
         accomodate the first mb character in the next conversion block */
      if (to_left < MB_CUR_MAX)
         break;
    }
  }

  from_left = from_len;
  from_cnvlen = 0;
  to_cnvlen = 0;
  /* BugId : 4253988. In case the from_buf is bigger than the to_buffer,
       we need to return the required buffer size and status as XBufferOverflow.
       We create a tmp buffer equals 8 times the from_len and do conversion.
  */
  to_left = (sizeof(wchar_t) * from_len) ;
  tmp_buf = (char *)malloc(to_left);
  for (;;) {
    from_savelen = from_left;
    from_buf = &from[from_cnvlen];
    to_savelen = to_left;
    to_buf = &tmp_buf[to_cnvlen];
    if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
                  (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
      *state = XLookupNone;
      return 0;
    }
    from_cnvlen += (from_savelen - from_left);
    to_cnvlen += (to_savelen - to_left);
    if (from_left == 0) {
      if (to_cnvlen > 0)
       *state = XBufferOverflow;
      else
       *state = XLookupNone;
      break;
    }
  }
  free(tmp_buf);
  return to_cnvlen;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IMConvertFromUTF8 ( char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
)

Definition at line 290 of file iiimpConv.c.

{
    size_t ret = 0;
#ifdef USE_CSCONV
    static csconv_t csconv_cd = NULL;
#endif

#ifdef USE_ICONV
    if (skip_native_to_utf8_conv)
       return -1;

    if (i_conv2_FromUTF16 == (iconv_t)-1)
       /* already failed */
       return -1;

    if (i_conv2_FromUTF16 == NULL) {
       char *encoding = nl_langinfo(CODESET);

       if (!strcmp(encoding, "UTF-8")) {
           skip_native_to_utf8_conv = True;
           return -1;
       } else {
           if ((i_conv2_FromUTF16 = iconv_open(encoding, "UTF-8"))
              == (iconv_t) - 1) {
              /* fallback */
              encoding = "646";
              if ((i_conv2_FromUTF16 = iconv_open(encoding, "UTF-8"))
                  == (iconv_t) - 1)
                  goto done;
           }
       }
    }

    ret = iconv(i_conv2_FromUTF16, (const char**)&from_buf, &from_left,
              to_buf, to_left);
done:
#endif /* USE_ICONV */

    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IMConvertFromUTF8ToUTF16 ( char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
)

Definition at line 255 of file iiimpConv.c.

{
    char *encoding;
    int ret;
#ifdef USE_CSCONV
    encoding = "en_US.UTF-8";
#else
    int restore = False;
    encoding = "UTF-8";
    if (!skip_native_to_utf8_conv) {
       restore = True;
       skip_native_to_utf8_conv = True;
    }
#endif
    ret = ConvertToUTF16(encoding,
                      from_buf, from_left,
                      to_buf, to_left);
#ifndef USE_CSCONV
    if (restore)
       skip_native_to_utf8_conv = False;
#endif

    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int IMConvertToUTF8 ( char *  from_buf,
size_t  from_left,
char **  to_buf,
size_t *  to_left 
)

Definition at line 341 of file iiimpConv.c.

{
  size_t ret = 0;
#ifdef USE_CSCONV
  static csconv_t csconv_cd = NULL;
#endif

#ifdef USE_ICONV
  if (skip_native_to_utf8_conv) {
    strcpy (to_buf, from_buf);
    *to_left -= from_left;
    return ret;
  }

  if (i_conv_ToUTF8 == (iconv_t)-1)
    /* already failed */
    return -1;

  if (i_conv_ToUTF8 == NULL) {
    char *encoding = nl_langinfo(CODESET);

    if (!strcmp(encoding, "UTF-8")) {
      skip_native_to_utf8_conv = True;
      strcpy (to_buf, from_buf);
      *to_left -= from_left;
      return ret;
    } else {
      if ((i_conv_ToUTF8 = iconv_open("UTF-8", encoding))
         == (iconv_t) - 1) {
       /* fallback */
       encoding = "646";
       if ((i_conv_ToUTF8 = iconv_open("UTF-8", encoding))
           == (iconv_t) - 1)
         goto done;
      }
    }
  }

  ret = iconv(i_conv_ToUTF8, (const char**)&from_buf, &from_left,
             to_buf, to_left);
 done:
#endif /* USE_ICONV */

  return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static IIIMF_status UTF16ToString ( int  len,
const IIIMP_card16 ucstr,
Bool  useUnicode,
char **  pstr 
) [static]

Definition at line 539 of file iiimpConv.c.

{
    if (len == 0) {
       *pstr = NULL;
       return IIIMF_STATUS_SUCCESS;
    }

    if (useUnicode) {
       IIIMP_card16 *ustr;

       ustr = (IIIMP_card16*) Xmalloc(sizeof(*ustr) * (len + 1));
       if (!ustr) return IIIMF_STATUS_MALLOC;
       memcpy(ustr, ucstr, sizeof(*ucstr) * len);
       ustr[len] = 0;
       *pstr = (char*) ustr;

       return IIIMF_STATUS_SUCCESS;
    } else {
       int dst_len, dst_len_orig, src_len;
       char *str;
       const char *src;

       str = (char*) Xmalloc(len * MB_CUR_MAX + 1);
       if (!str) return IIIMF_STATUS_MALLOC;
       dst_len = dst_len_orig = len * MB_CUR_MAX;
       src_len = len * sizeof(IIIMP_card16);

       src = (const char*) ucstr;
       IIimpConvertFromUTF16(src, src_len, &str, &dst_len);
       str[dst_len_orig - dst_len] = '\0';
       *pstr = str;
    }

    return IIIMF_STATUS_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

iconv_t i_conv1 = NULL [static]

Definition at line 95 of file iiimpConv.c.

iconv_t i_conv1_FromUTF16 = NULL [static]

Definition at line 285 of file iiimpConv.c.

iconv_t i_conv2 = NULL [static]

Definition at line 96 of file iiimpConv.c.

iconv_t i_conv2_FromUTF16 = NULL [static]

Definition at line 286 of file iiimpConv.c.

iconv_t i_conv_ToUTF8 = NULL [static]

Definition at line 337 of file iiimpConv.c.

Definition at line 97 of file iiimpConv.c.