Logo Search packages:      
Sourcecode: maradns version File versions

l1toutf8.c

/* Placed in the public domain 2001 by Sam Trenholme */

#include <stdio.h>

/* Convert an iso 8859-1 string in to a UTF-8 string.
   input: iso 8859-1 character
   output: output to stadnard output utf-8 (or ASCII) sequence
*/

int iso88591_to_utf8(unsigned char i8859) {
   

        if(i8859 <= 0x7f) {
          printf("%c",i8859);
          }
        else { /* Convert it to UTF8 */
          printf("%c%c",(i8859 >> 6) | 0xc0,(i8859 & 0x3f) | 0x80);
          }

    }

main() {
    unsigned char x;
    while(!feof(stdin)) {
       x = getc(stdin);
       if(!feof(stdin)) 
           iso88591_to_utf8(x);
       fflush(stdout);
       }
    }


Generated by  Doxygen 1.6.0   Back to index