File: TestModernIconv.c

package info (click to toggle)
calligra 1%3A2.8.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 397,516 kB
  • ctags: 185,064
  • sloc: cpp: 1,505,875; python: 45,987; ansic: 28,421; xml: 26,472; sh: 23,986; java: 18,214; objc: 3,965; makefile: 2,816; perl: 2,792; yacc: 2,601; lex: 1,410; sql: 903; ruby: 737; asm: 236; lisp: 121
file content (41 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (11)
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
#ifdef HAVE_ICONV_H
#include <iconv.h>
#endif
#ifdef HAVE_SYS_ICONV_H
#include <sys/iconv.h>
#endif
#include <stdlib.h>

int check( const char* from, const char* to )
{
    iconv_t myConverter = iconv_open( to, from );

    if ( myConverter != (iconv_t)-1 ) {
	iconv_close( myConverter );
	return 0;
    }
    else
	return 1;
}

int main(int argc, char** argv)
{
    const char* from[] = { "CP874", "CP932", "CP936", "CP949",
			   "CP950", "CP1250", "CP1251", "CP1252",
			   "CP1253", "CP1254", "CP1255", "CP1256",
			   "CP1257", "koi8-r", 0 };
    const char* to[] = { "UNICODELITTLE", "UNICODEBIG", 0 };
    int fromIndex = 0;
    int toIndex = 0;

    while ( to[ toIndex ] != 0 ) {
	while( from[ fromIndex ] != 0 ) {
	    if ( check( from[ fromIndex ], to[ toIndex ] ) != 0 )
		exit( 1 );
	    fromIndex = fromIndex + 1;
	}
	toIndex = toIndex + 1;
	fromIndex = 0;
    }
    exit( 0 );
}