comparison src/util.c @ 7287:3a41c3f80228

[gaim-migrate @ 7868] more fun html entity stuff committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 17 Oct 2003 05:58:16 +0000
parents d565594c1bae
children ab828b8c3f22
comparison
equal deleted inserted replaced
7286:0b961945c8ae 7287:3a41c3f80228
788 788
789 xhtml = g_string_append(xhtml, "&lt;"); 789 xhtml = g_string_append(xhtml, "&lt;");
790 plain = g_string_append_c(plain, '<'); 790 plain = g_string_append_c(plain, '<');
791 c++; 791 c++;
792 } 792 }
793 } else if(*c == '&') {
794 char buf[7];
795 char *pln;
796 int len = 1;
797 guint pound;
798 if(!g_ascii_strncasecmp(c, "&amp;", 5)) {
799 pln = "&";
800 len = 5;
801 } else if(!g_ascii_strncasecmp(c, "&lt;", 4)) {
802 pln = "<";
803 len = 4;
804 } else if(!g_ascii_strncasecmp(c, "&gt;", 4)) {
805 pln = ">";
806 len = 4;
807 } else if(!g_ascii_strncasecmp(c, "&nbsp;", 6)) {
808 pln = " ";
809 len = 6;
810 } else if(!g_ascii_strncasecmp(c, "&copy;", 6)) {
811 pln = "©";
812 len = 6;
813 } else if(!g_ascii_strncasecmp(c, "&quot;", 6)) {
814 pln = "\"";
815 len = 6;
816 } else if(!g_ascii_strncasecmp(c, "&reg;", 5)) {
817 pln = "®";
818 len = 5;
819 } else if(!g_ascii_strncasecmp(c, "&apos;", 6)) {
820 pln = "\'";
821 len = 6;
822 } else if(*(c+1) == '#' && (sscanf(c, "&#%u;", &pound) == 1) &&
823 pound != 0 && *(c+3+(gint)log10(pound)) == ';') {
824 int buflen = g_unichar_to_utf8((gunichar)pound, buf);
825 buf[buflen] = '\0';
826 pln = buf;
827
828
829 len = 2;
830 while(isdigit((gint) c [len])) len++;
831 if(c [len] == ';') len++;
832 } else {
833 len = 1;
834 g_snprintf(buf, sizeof(buf), "%c", *c);
835 pln = buf;
836 }
837 xhtml = g_string_append_len(xhtml, c, len);
838 plain = g_string_append(plain, pln);
839 c += len;
793 } else { 840 } else {
794 xhtml = g_string_append_c(xhtml, *c); 841 xhtml = g_string_append_c(xhtml, *c);
795 plain = g_string_append_c(plain, *c); 842 plain = g_string_append_c(plain, *c);
796 c++; 843 c++;
797 } 844 }