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
);
38 resolve_xml_special_chars (buf
);
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
= convert_xml_special_chars (in
);
54 if (strcmp (buf
, out
))
56 printf (" ERROR: got \"%s\"\n", buf
);
64 (void)setvbuf (stdout
, NULL
, _IONBF
, 0);
65 decode ("This should not be modified 1234",
66 "This should not be modified 1234");
68 decode ("Rémi François & Émile",
69 "Rémi François & Émile");
73 /* tests with invalid input */
74 decode ("&<\"'", "&<\"'");
75 decode ("&oelig", "&oelig");
78 encode ("a'àc\"çe&én<ño>ö1:", "a'àc"çe&én<ño>ö1:");
79 encode ("\x01\xC2\x81\xC2\x85", "\xC2\x85");
80 encode ("\r\n", "\r\n");