Mercurial > pidgin
comparison src/util.c @ 10800:8002e95c0809
[gaim-migrate @ 12446]
Fix URL and filename encoding in non-UTF8 locales where isalnum is true for
some non-ASCII characters
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 09 Apr 2005 14:12:38 +0000 |
parents | c4cb90065e1d |
children | 6240d7fd5b2c |
comparison
equal
deleted
inserted
replaced
10799:6f67d4088da0 | 10800:8002e95c0809 |
---|---|
3073 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); | 3073 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); |
3074 | 3074 |
3075 iter = str; | 3075 iter = str; |
3076 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { | 3076 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { |
3077 gunichar c = g_utf8_get_char(iter); | 3077 gunichar c = g_utf8_get_char(iter); |
3078 /* If the character is an ASCII character and is alphanumeric, | 3078 /* If the character is an ASCII character and is alphanumeric |
3079 * or one of the specified values, no need to escape */ | 3079 * no need to escape */ |
3080 if (c < 256 && isalnum(c)) { | 3080 if (c < 128 && isalnum(c)) { |
3081 buf[j++] = c; | 3081 buf[j++] = c; |
3082 } else { | 3082 } else { |
3083 int bytes = g_unichar_to_utf8(c, utf_char); | 3083 int bytes = g_unichar_to_utf8(c, utf_char); |
3084 for (i = 0; i < bytes; i++) { | 3084 for (i = 0; i < bytes; i++) { |
3085 if (j > (BUF_LEN - 4)) | 3085 if (j > (BUF_LEN - 4)) |
3450 iter = str; | 3450 iter = str; |
3451 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { | 3451 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { |
3452 gunichar c = g_utf8_get_char(iter); | 3452 gunichar c = g_utf8_get_char(iter); |
3453 /* If the character is an ASCII character and is alphanumeric, | 3453 /* If the character is an ASCII character and is alphanumeric, |
3454 * or one of the specified values, no need to escape */ | 3454 * or one of the specified values, no need to escape */ |
3455 if (c < 256 && (isalnum(c) || c == '@' || c == '-' || | 3455 if (c < 128 && (isalnum(c) || c == '@' || c == '-' || |
3456 c == '_' || c == '.' || c == '#')) { | 3456 c == '_' || c == '.' || c == '#')) { |
3457 buf[j++] = c; | 3457 buf[j++] = c; |
3458 } else { | 3458 } else { |
3459 int bytes = g_unichar_to_utf8(c, utf_char); | 3459 int bytes = g_unichar_to_utf8(c, utf_char); |
3460 for (i = 0; i < bytes; i++) { | 3460 for (i = 0; i < bytes; i++) { |