Changeset a252c1a for protocols/yahoo/yahoo_util.c
- Timestamp:
- 2005-12-31T20:29:15Z (19 years ago)
- Branches:
- master
- Children:
- 39cc341
- Parents:
- c88999c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/yahoo_util.c
rc88999c ra252c1a 50 50 51 51 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;102 52 } 103 53
Note: See TracChangeset
for help on using the changeset viewer.