blob: 7ed11bf58773f5c45bfc0e60e9e956d2722d6707 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/* ----------------------------------------------------------------------------
* $ gcc -Wall -o sample sample.c -L. -lunijp
* ------------------------------------------------------------------------- */
#include "unijp.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int test_conv(const char* text_utf8, uj_charcode_t ocode)
{
uj_charcode_t icode = ujc_utf8;
size_t in_bytes;
unijp_t* uj;
uj_uint8* obuf;
uj_size_t obuf_len;
in_bytes = strlen(text_utf8);
uj = uj_new((uj_uint8*)text_utf8, in_bytes, icode);
if( uj==NULL )
{
fprintf(stderr, "uj_new: %s: %s\n", "-", strerror(errno));
return 1;
}
obuf = uj_conv(uj, ocode, &obuf_len);
if( obuf==NULL )
{
fprintf(stderr, "uj_conv: %s: %s\n", "-", strerror(errno));
return 1;
}
printf("sjis result: %s\n", obuf);
free(obuf);
uj_delete(uj);
return 0;
}
int main()
{
int r;
const char* text_utf8 = "ใในใ";
r = test_conv(text_utf8, ujc_sjis);
return r;
}
/* ----------------------------------------------------------------------------
* End of File.
* ------------------------------------------------------------------------- */
|