Changeset a252c1a
- Timestamp:
- 2005-12-31T20:29:15Z (19 years ago)
- Branches:
- master
- Children:
- 39cc341
- Parents:
- c88999c
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
rc88999c ra252c1a 1856 1856 xmlnode_insert_cdata(y, "away", -1); 1857 1857 y = xmlnode_insert_tag(x, "status"); 1858 { 1859 char *utf8 = str_to_utf8(message); 1860 xmlnode_insert_cdata(y, utf8, -1); 1861 g_free(utf8); 1862 } 1858 xmlnode_insert_cdata(y, message, -1); 1863 1859 gc->away = ""; 1864 1860 } else { -
protocols/nogaim.h
rc88999c ra252c1a 291 291 292 292 /* util.c */ 293 G_MODULE_EXPORT char *utf8_to_str( const char *in );294 G_MODULE_EXPORT char *str_to_utf8( const char *in );295 293 G_MODULE_EXPORT void strip_linefeed( gchar *text ); 296 294 G_MODULE_EXPORT char *add_cr( char *text ); … … 299 297 G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec ); 300 298 G_MODULE_EXPORT void strip_html( char *msg ); 301 G_MODULE_EXPORT char * escape_html(const char *html);299 G_MODULE_EXPORT char *escape_html( const char *html ); 302 300 G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value); 303 301 -
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 -
util.c
rc88999c ra252c1a 38 38 #include <glib.h> 39 39 #include <time.h> 40 41 char *utf8_to_str(const char *in)42 {43 int n = 0, i = 0;44 int inlen;45 char *result;46 47 if (!in)48 return NULL;49 50 inlen = strlen(in);51 52 result = g_malloc(inlen + 1);53 54 while (n <= inlen - 1) {55 long c = (long)in[n];56 if (c < 0x80)57 result[i++] = (char)c;58 else {59 if ((c & 0xC0) == 0xC0)60 result[i++] =61 (char)(((c & 0x03) << 6) | (((unsigned char)in[++n]) & 0x3F));62 else if ((c & 0xE0) == 0xE0) {63 if (n + 2 <= inlen) {64 result[i] =65 (char)(((c & 0xF) << 4) | (((unsigned char)in[++n]) & 0x3F));66 result[i] =67 (char)(((unsigned char)result[i]) |68 (((unsigned char)in[++n]) & 0x3F));69 i++;70 } else71 n += 2;72 } else if ((c & 0xF0) == 0xF0)73 n += 3;74 else if ((c & 0xF8) == 0xF8)75 n += 4;76 else if ((c & 0xFC) == 0xFC)77 n += 5;78 }79 n++;80 }81 result[i] = '\0';82 83 return result;84 }85 86 char *str_to_utf8(const char *in)87 {88 int n = 0, i = 0;89 int inlen;90 char *result = NULL;91 92 if (!in)93 return NULL;94 95 inlen = strlen(in);96 97 result = g_malloc(inlen * 2 + 1);98 99 while (n < inlen) {100 long c = (long)in[n];101 if (c == 27) {102 n += 2;103 if (in[n] == 'x')104 n++;105 if (in[n] == '3')106 n++;107 n += 2;108 continue;109 }110 /* why are we removing newlines and carriage returns?111 if ((c == 0x0D) || (c == 0x0A)) {112 n++;113 continue;114 }115 */116 if (c < 128)117 result[i++] = (char)c;118 else {119 result[i++] = (char)((c >> 6) | 192);120 result[i++] = (char)((c & 63) | 128);121 }122 n++;123 }124 result[i] = '\0';125 126 return result;127 }128 40 129 41 void strip_linefeed(gchar *text)
Note: See TracChangeset
for help on using the changeset viewer.