1 /* Compilation: 2 * gcc wordbreak_test.c `pkg-config --libs --cflags libunibreak` 3 * 4 * Note: Output is not aligned nicely when used with non-ascii chars. 5 */ 6 7 #include <stdlib.h> 8 #include <stdio.h> 9 #include <string.h> 10 #include <wordbreak.h> 11 12 int main(int argc,char * argv[])13main(int argc, char *argv[]) 14 { 15 const char *lang = ""; 16 const char *text; 17 size_t len; 18 char *breaks; 19 size_t i; 20 21 if (argc != 2) 22 { 23 printf("Usage: %s <text>\n", argv[0]); 24 exit(1); 25 } 26 27 text = argv[1]; 28 len = strlen(text); 29 breaks = malloc(len); 30 printf("%s\n", text); 31 32 set_wordbreaks_utf8((const utf8_t *) text, len, lang, breaks); 33 for (i = 0 ; i < len ; i++) 34 printf("%d", (int) breaks[i]); 35 printf("\n"); 36 37 return 0; 38 } 39