Read text from file and print each character in separate line

[LEFT]performing this code to read from file and print each character in separate line
works well with ASCII encoded text[/LEFT]

 
 
void
preprocess_file (FILE *fp)
{
  int cc;
    for (;;)
      {  cc = getc (fp);
 if (cc == EOF)
     break;
 printf ("%c\n", cc);
  
      }
}
int
main(int argc, char *argv [])
{
    preprocess_file (stdin);
    exit (0);
}
 

but when i use it with UTF-8 encoded text it shows unreadable character such as

 �
�


�

�

�

�

�
 

any help? Thanks

Have you already seen the getwchar() function? getc() like getchar() reads only one byte at time so fails with UTF8.

Emanuele