void test_for_convert() { iconv_t it; size_t li, lo, result; char *t, *ti; char toi[100],to[100], *tob, *toai; ti = "Test проверка"; t = natspec_convert(ti, "ASCII", NULL, 1); printf("1 %s -> '%s'\n",ti,t); t = natspec_convert(ti, "UTF8", "", 1); printf("2 %s -> '%s'\n",ti,t); ti = natspec_convert(t, "", "UTF8", 1); printf("3 %s -> '%s'\n",t,ti); ti = "оПНБЕПЙЮ"; t = natspec_convert(ti, "", "CP1251", 1); printf("%s -> '%s'\n",ti,t); ti = "оПНБЕПЙЮ"; t = natspec_convert(ti, "", "CP1251", 0); printf("%s -> '%s'\n",ti,t); ti = "оПНБЕПЙЮ \xb9"; t = natspec_convert(ti, "", "CP1251", 0); printf("%s -> '%s'\n",ti,t); ti = "Test Проверка"; t = natspec_convert(ti, "IBM866", "KOI8R", 0); printf("%s -> '%s'\n",ti,t); it = natspec_iconv_open("aSCII", ""); if ( it == (iconv_t)(-1)) { printf("natspec_iconv: some problems\n"); exit (1); } strcpy(toi,"Test - Проверка ёлочных игрушек."); li = strlen(toi); lo = 99; tob = to; toai = toi; printf("Before natspec_iconv: it=%d, %s, len=%d\n", (int)it, toi, li); result = natspec_iconv(it, &toai, &li, &tob, &lo, 1); *tob = '\0'; printf("Result natspec_iconv: %s (lo=%d), with result=%d\n", to, lo, result); natspec_iconv_close(it); }
/* Obsoleted */ char *natspec_convert_with_translit(const char *in_str, const char *tocode, const char *fromcode) { return natspec_convert(in_str, tocode, fromcode, 1); }