Set license using %license
[platform/upstream/fribidi.git] / bin / fribidi-caprtl2utf8.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <fribidi.h>
4
5 char buf[BUFSIZ];
6 FriBidiChar ubuf[BUFSIZ];
7
8 int
9 main (
10   void
11 )
12 {
13   FriBidiCharSet caprtl = fribidi_parse_charset ("CapRTL");
14   FriBidiCharSet utf8 = fribidi_parse_charset ("UTF-8");
15
16   while (fgets (buf, sizeof buf, stdin))
17     {
18       char eol[5];
19
20       FriBidiStrIndex len = strlen (buf);
21       while (len && (buf[len - 1] == '\n' || buf[len - 1] == '\r'))
22         len--;
23       strncpy (eol, buf + len, sizeof eol);
24       buf[len] = 0;
25
26       len = fribidi_charset_to_unicode (caprtl, buf, len, ubuf);
27       fprintf (stderr, "%d\n", len);
28       len = fribidi_unicode_to_charset (utf8, ubuf, len, buf);
29
30       buf[len] = 0;
31       printf ("%s%s", buf, eol);
32     }
33
34   return 0;
35 }