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 (s: "CapRTL" ); |
14 | FriBidiCharSet utf8 = fribidi_parse_charset (s: "UTF-8" ); |
15 | |
16 | while (fgets (s: buf, n: sizeof buf, stdin)) |
17 | { |
18 | char eol[5]; |
19 | |
20 | FriBidiStrIndex len = strlen (s: buf); |
21 | while (len && (buf[len - 1] == '\n' || buf[len - 1] == '\r')) |
22 | len--; |
23 | strncpy (dest: eol, src: buf + len, n: sizeof eol); |
24 | buf[len] = 0; |
25 | |
26 | len = fribidi_charset_to_unicode (char_set: caprtl, s: buf, len, us: ubuf); |
27 | fprintf (stderr, format: "%d\n" , len); |
28 | len = fribidi_unicode_to_charset (char_set: utf8, us: ubuf, len, s: buf); |
29 | |
30 | buf[len] = 0; |
31 | printf (format: "%s%s" , buf, eol); |
32 | } |
33 | |
34 | return 0; |
35 | } |
36 | |