65c2c54cfb
git-subtree-dir: fribidi/fribidi git-subtree-split: 27b9250ca4dd328bcc8eff6fd4d72914a0b6bde7
35 lines
736 B
C
35 lines
736 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <fribidi.h>
|
|
|
|
char buf[BUFSIZ];
|
|
FriBidiChar ubuf[BUFSIZ];
|
|
|
|
int
|
|
main (
|
|
void
|
|
)
|
|
{
|
|
FriBidiCharSet caprtl = fribidi_parse_charset ("CapRTL");
|
|
FriBidiCharSet utf8 = fribidi_parse_charset ("UTF-8");
|
|
|
|
while (fgets (buf, sizeof buf, stdin))
|
|
{
|
|
char eol[5];
|
|
|
|
FriBidiStrIndex len = strlen (buf);
|
|
while (len && (buf[len - 1] == '\n' || buf[len - 1] == '\r'))
|
|
len--;
|
|
strncpy (eol, buf + len, sizeof eol);
|
|
buf[len] = 0;
|
|
|
|
len = fribidi_charset_to_unicode (caprtl, buf, len, ubuf);
|
|
fprintf (stderr, "%d\n", len);
|
|
len = fribidi_unicode_to_charset (utf8, ubuf, len, buf);
|
|
|
|
buf[len] = 0;
|
|
printf ("%s%s", buf, eol);
|
|
}
|
|
|
|
return 0;
|
|
}
|