/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
char* ISO88959ToUTF8(const char *str)
{
char* utf8 = (char*) malloc(1 + (2 * strlen(str)));
int len = 0;
char *c = utf8;
for (; *str; ++str) {
if (!(*str & 0x80)) {
*c++ = *str;
len++;
} else {
*c++ = (char) (0xc2 | ((unsigned char)(*str) >> 6));
*c++ = (char) ((0xbf & *str));
printf("%x\n", (char) ((0xbf & *str)));
len += 2;
}
}
*c++ = '\0';
realloc(utf8, len);
return utf8;
}
int main()
{
printf(ISO88959ToUTF8("\x79\x78\xd8"));
return 0;
}