Logo Search packages:      
Sourcecode: freetds version File versions

char* tds7_ascii2unicode ( TDSSOCKET *  tds,
const char *  in_string,
char *  out_string,
int  maxlen 

convert a ascii string to ucs2. Note: output string is not terminated

in_string string to translate, null terminated
out_string buffer to store translated string
maxlen length of out_string buffer in bytes

Definition at line 187 of file iconv.c.

References tds7_ascii2unicode().

Referenced by tds7_ascii2unicode(), and tds_put_string().

      register int out_pos = 0;
      register int i;
      size_t string_length;

      TDSICONVINFO *iconv_info;
      ICONV_CONST char *in_ptr;
      char *out_ptr;
      size_t out_bytes, in_bytes;

      if (!in_string)
            return NULL;
      string_length = strlen(in_string);

      iconv_info = (TDSICONVINFO *) tds->iconv_info;
      if (iconv_info->use_iconv) {
            out_bytes = maxlen;
            in_bytes = string_length;
            in_ptr = (ICONV_CONST char *) in_string;
            out_ptr = out_string;
            iconv(iconv_info->cdto, &in_ptr, &in_bytes, &out_ptr, &out_bytes);

            return out_string;

      /* no iconv, add null high order byte to convert 7bit ascii to unicode */
      if (string_length * 2 > maxlen)
            string_length = maxlen >> 1;

      for (i = 0; i < string_length; i++) {
            out_string[out_pos++] = in_string[i];
            out_string[out_pos++] = '\0';

      return out_string;

Generated by  Doxygen 1.6.0   Back to index