Hash :
110a0f7b
Author :
Date :
2020-10-14T23:01:01
os2: update include paths. add missing libc includes to geniconv.
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
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "geniconv.h"
int main(void)
{
char acBuf[128];
char *inbuf = "Тест - проверка"; // KOI8-R string.
size_t inbytesleft = strlen( inbuf );
char *outbuf = &acBuf;
size_t outbytesleft = sizeof( acBuf );
iconv_t ic;
// KOI8 -> system cp.
ic = iconv_open( "", "KOI8-R" );
if ( ic == (iconv_t)(-1) )
{
puts( "iconv_open() fail" );
return 1;
}
iconv( ic, &inbuf, &inbytesleft, &outbuf, &outbytesleft );
printf( "KOI8-R to system cp.: %s\n", &acBuf );
iconv_close( ic );
// System cp. -> UTF-8 -> system cp.
// System cp. -> UTF-8 by StrUTF8New().
inbuf = StrUTF8New( 1, &acBuf, strlen( &acBuf ) );
// UTF-8 -> system cp. by StrUTF8().
if ( StrUTF8( 0, &acBuf, sizeof(acBuf), inbuf, strlen( inbuf ) ) == -1 )
puts( "StrUTF8() failed" );
else
printf( "system cp. -> UTF-8 -> system cp.: %s\n", &acBuf );
free( inbuf );
// Unload used DLL.
iconv_clean();
puts( "Done." );
return 0;
}