Allow to specify charset and encoding from the command line.
Showing
1 changed file
with
20 additions
and
1 deletions
... | @@ -26,7 +26,26 @@ | ... | @@ -26,7 +26,26 @@ |
26 | int | 26 | int |
27 | main (int argc, char *argv[]) | 27 | main (int argc, char *argv[]) |
28 | { | 28 | { |
29 | int c; | ||
29 | char buf[256]; | 30 | char buf[256]; |
31 | char *charset = "iso-8859-1"; | ||
32 | char *encoding = "quoted-printable"; | ||
33 | |||
34 | while ((c = getopt (argc, argv, "c:e:h")) != EOF) | ||
35 | switch (c) | ||
36 | { | ||
37 | case 'c': | ||
38 | charset = optarg; | ||
39 | break; | ||
40 | case 'e': | ||
41 | encoding = optarg; | ||
42 | break; | ||
43 | case 'h': | ||
44 | printf ("usage: %s [-c charset] [-e encoding]\n", argv[0]); | ||
45 | exit (0); | ||
46 | default: | ||
47 | exit (1); | ||
48 | } | ||
30 | 49 | ||
31 | while (fgets (buf, sizeof (buf), stdin)) | 50 | while (fgets (buf, sizeof (buf), stdin)) |
32 | { | 51 | { |
... | @@ -36,7 +55,7 @@ main (int argc, char *argv[]) | ... | @@ -36,7 +55,7 @@ main (int argc, char *argv[]) |
36 | len = strlen (buf); | 55 | len = strlen (buf); |
37 | if (len > 0 && buf[len - 1] == '\n') | 56 | if (len > 0 && buf[len - 1] == '\n') |
38 | buf[len - 1] = 0; | 57 | buf[len - 1] = 0; |
39 | rc = mu_rfc2047_encode ("iso-8859-1", "quoted-printable", buf, &p); | 58 | rc = mu_rfc2047_encode (charset, encoding, buf, &p); |
40 | printf ("%s=> %s\n", buf, mu_strerror (rc)); | 59 | printf ("%s=> %s\n", buf, mu_strerror (rc)); |
41 | if (p) | 60 | if (p) |
42 | printf ("%s\n", p); | 61 | printf ("%s\n", p); | ... | ... |
-
Please register or sign in to post a comment