4 #include <stringprep_nameprep.h>
7 * Compiling using libtool and pkg-config is recommended:
9 * $ libtool cc -o example example.c `pkg-config --cflags --libs libstringprep`
11 * Input string encoded as `ISO-8859-1': ยช
12 * Before locale2utf (length 2): aa 0a
13 * Before stringprep (length 3): c2 aa 0a
14 * After stringprep (length 2): 61 0a
20 main (int argc
, char *argv
[])
26 printf ("Input string encoded as `%s': ", stringprep_locale_charset ());
28 fgets (buf
, BUFSIZ
, stdin
);
30 printf ("Before locale2utf (length %d): ", strlen (buf
));
31 for (i
= 0; i
< strlen (buf
); i
++)
32 printf ("%02x ", buf
[i
] & 0xFF);
35 p
= stringprep_locale_to_utf8 (buf
);
42 printf ("Could not convert string to UTF-8, continuing anyway...\n");
44 printf ("Before stringprep (length %d): ", strlen (buf
));
45 for (i
= 0; i
< strlen (buf
); i
++)
46 printf ("%02x ", buf
[i
] & 0xFF);
49 rc
= stringprep (buf
, BUFSIZ
, 0, stringprep_nameprep
);
50 if (rc
!= STRINGPREP_OK
)
51 printf ("Stringprep failed with rc %d...\n", rc
);
54 printf ("After stringprep (length %d): ", strlen (buf
));
55 for (i
= 0; i
< strlen (buf
); i
++)
56 printf ("%02x ", buf
[i
] & 0xFF);