Back to index

php5  5.3.10
sample.c
Go to the documentation of this file.
00001 
00008 #include <stdio.h>
00009 #include "../mbfl/mbfilter.h"
00010 
00011 int main()
00012 {
00013        enum mbfl_no_encoding from_encoding, to_encoding;
00014        enum mbfl_no_language no_language;
00015        mbfl_buffer_converter *convd = NULL;
00016        mbfl_string string, result, *ret;
00017        mbfl_language lang;
00018        unsigned char input[] = "日本語文字列"; /* EUC-JP kanji string */
00019 
00020        no_language = mbfl_name2no_language("Japanese");
00021        from_encoding = mbfl_name2no_encoding("EUC-JP");
00022        to_encoding = mbfl_name2no_encoding("SJIS");
00023 
00024        mbfl_string_init(&string);
00025        mbfl_string_init(&result);
00026 
00027        string.no_encoding = from_encoding;
00028        string.no_language = no_language;
00029        string.val = (unsigned char *)input;
00030        string.len = strlen(input);
00031 
00032        convd = mbfl_buffer_converter_new(from_encoding, to_encoding, 0);
00033        ret = mbfl_buffer_converter_feed_result(convd, &string, &result);
00034        mbfl_buffer_converter_delete(convd);      
00035 
00036        puts(ret->val);
00037        return 1;
00038 }