Sindbad~EG File Manager

Current Path : /home/beeson/public_html/WebMathXpert/Examples/
Upload File :
Current File : //home/beeson/public_html/WebMathXpert/Examples/UTF8Example.c

#include <stdio.h>

int main() {
    char *utf8String = "Hello, 你好, こんにちは";

    for (char *ptr = utf8String; *ptr != '\0'; ) {
        // Determine the number of bytes in the current character
        int bytes = 1;
        if ((*ptr & 0xC0) == 0xC0) {
            bytes = 2;
            if ((*ptr & 0xE0) == 0xE0) {
                bytes = 3;
                if ((*ptr & 0xF0) == 0xF0) {
                    bytes = 4;
                }
            }
        }

        // Print the current character
        for (int i = 0; i < bytes; i++) {
            putchar(*ptr);
            ptr++;
        }

        //printf(" ");  // Separate characters with a space
    }
	 
	 //printf("\n%s",utf8String);
	 printf("\n%s", "done");
    return 0;
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists