Hello!

I'm trying to convert ANSI characters to UTF8 that but it doesn't
work correctly.

I used the following:

void main() {
        writeln(convertToUTF8("�"));
}

string convertToUTF8(string text) {

        string result;

        for (uint i=0; i<text.length; i++) {
                char ch = text[i];
                if (ch < 0x80) {
                        result ~= ch;
                } else {
                        result ~= 0xC0 | (ch >> 6);
                        result ~= 0x80 | (ch & 0x3F);
                }
        }
        return result;

}

But writeln doesn't print anything (only a blank line), but not my
character. The same problem exists for similar characters like � or �.

Is there anything I'm doing wrong?

Reply via email to