1 /*****************************************************************************
2 * xmlent.c: Test for XML entities
3 *****************************************************************************
4 * Copyright (C) 2006, 2008 Rémi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
29 #include <vlc_common.h>
30 #include <vlc_strings.h>
32 static void decode (const char *in
, const char *out
)
34 char buf
[strlen (in
) + 1];
36 printf ("\"%s\" -> \"%s\" ?\n", in
, out
);
40 if (strcmp (buf
, out
))
42 printf (" ERROR: got \"%s\"\n", buf
);
47 static void encode (const char *in
, const char *out
)
51 printf ("\"%s\" -> \"%s\" ?\n", in
, out
);
52 buf
= vlc_xml_encode (in
);
56 puts(" ERROR: got NULL");
60 if (strcmp (buf
, out
))
62 printf (" ERROR: got \"%s\"\n", buf
);
70 (void)setvbuf (stdout
, NULL
, _IONBF
, 0);
71 decode ("This should not be modified 1234",
72 "This should not be modified 1234");
74 decode ("Rémi François & Émile",
75 "Rémi François & Émile");
76 decode ("Rémi François & Émile",
77 "Rémi François & Émile");
78 decode ("Rémi François & Émile",
79 "Rémi François & Émile");
80 decode ("Rémi François & Émile",
81 "Rémi François & Émile");
85 /* tests with invalid input */
86 decode ("&<\"'", "&<\"'");
87 decode ("&oelig", "&oelig");
90 encode ("a'àc\"çe&én<ño>ö1:", "a'àc"çe&én<ño>ö1:");
91 encode ("\xC2\x81\xC2\x85", "\xC2\x85");
92 encode (" \t\r\n", " \t\r\n");