Ignore:
Timestamp:
2006-01-23T23:28:13Z (18 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
ec3e411
Parents:
7308b63 (diff), 68c7c14 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from Wilmer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/yahoo_util.c

    r7308b63 r9fae35c  
    5050
    5151        return new_string;
    52 }
    53 
    54 char * y_str_to_utf8(const char *in)
    55 {
    56         unsigned int n, i = 0;
    57         char *result = NULL;
    58 
    59         if(in == NULL || *in == '\0')
    60                 return "";
    61        
    62         result = y_new(char, strlen(in) * 2 + 1);
    63 
    64         /* convert a string to UTF-8 Format */
    65         for (n = 0; n < strlen(in); n++) {
    66                 unsigned char c = (unsigned char)in[n];
    67 
    68                 if (c < 128) {
    69                         result[i++] = (char) c;
    70                 } else {
    71                         result[i++] = (char) ((c >> 6) | 192);
    72                         result[i++] = (char) ((c & 63) | 128);
    73                 }
    74         }
    75         result[i] = '\0';
    76         return result;
    77 }
    78 
    79 char * y_utf8_to_str(const char *in)
    80 {
    81         int i = 0;
    82         unsigned int n;
    83         char *result = NULL;
    84 
    85         if(in == NULL || *in == '\0')
    86                 return "";
    87        
    88         result = y_new(char, strlen(in) + 1);
    89 
    90         /* convert a string from UTF-8 Format */
    91         for (n = 0; n < strlen(in); n++) {
    92                 unsigned char c = in[n];
    93 
    94                 if (c < 128) {
    95                         result[i++] = (char) c;
    96                 } else {
    97                         result[i++] = (c << 6) | (in[++n] & 63);
    98                 }
    99         }
    100         result[i] = '\0';
    101         return result;
    10252}
    10353
Note: See TracChangeset for help on using the changeset viewer.