45 lines
990 B
C++
45 lines
990 B
C++
//---------------------------------------------------------------------------
|
|
|
|
#include <vcl.h>
|
|
#pragma hdrstop
|
|
|
|
#include <tchar.h>
|
|
//---------------------------------------------------------------------------
|
|
#include <stdio.h>
|
|
#include <iconv.h>
|
|
#include <errno.h>
|
|
//#include <err.h>
|
|
|
|
#pragma argsused
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
{
|
|
iconv_t cd;
|
|
size_t k, f, t;
|
|
int se;
|
|
const char *code = "Âîïðîñ!";
|
|
const char* in = code;
|
|
char buf[100];
|
|
char* out = buf;
|
|
|
|
cd = iconv_open("cp1251", "koi8-r");
|
|
if( cd == (iconv_t)(-1) )
|
|
//err( 1, "iconv_open" );
|
|
fprintf (stderr, "iconv_open");
|
|
f = strlen(code);
|
|
t = sizeof buf;
|
|
memset( &buf, 0, sizeof buf );
|
|
errno = 0;
|
|
k = iconv(cd, &in, &f, &out, &t);
|
|
se = errno;
|
|
printf( "converted: %u,error=%d\n", (unsigned) k, se );
|
|
|
|
printf("string: %s\n", buf);
|
|
|
|
iconv_close(cd);
|
|
|
|
system ("pause");
|
|
return 0;
|
|
}
|
|
//---------------------------------------------------------------------------
|