Created
June 18, 2019 20:45
-
-
Save gurneyalex/0b55af3b2be3fb2eab087d9887911ce2 to your computer and use it in GitHub Desktop.
Test C program for iconv with translit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iconv.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <locale.h> | |
int main(){ | |
iconv_t cd; | |
cd = iconv_open("ascii//TRANSLIT", "utf-8"); | |
setlocale(LC_CTYPE, "fr_FR"); // important or TRANSLIT will output '?' for unsupport chars | |
char *input = "Lalalà Thérèse"; | |
char *originput = input; | |
char *output = malloc(500 *sizeof(char)); | |
char *origoutput = output; | |
size_t inputlen = strlen(input)*sizeof(char); | |
size_t outputlen = 500*sizeof(char); | |
size_t result = iconv(cd, &input, &inputlen, &output, &outputlen); | |
printf("%s\n", origoutput); | |
iconv_close(cd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment