Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Converting UTF-8 symbols to ANSI
- stock ConvertUTF8ToANSI(const utf8str[])
- {
- new ansistr[1024], i = 0, j = 0;
- while(utf8str[i] != 0 && j < sizeof(ansistr) - 1)
- {
- if((utf8str[i] & 0x80) == 0) ansistr[j++] = utf8str[i++];
- else if((utf8str[i] & 0xE0) == 0xC0)
- {
- new symbol = ((utf8str[i] & 0x1F) << 6) | (utf8str[i + 1] & 0x3F);
- switch(symbol)
- {
- case 0x0410..0x044F: ansistr[j++] = symbol - 0x0350;
- default: ansistr[j++] = '?';
- }
- i += 2;
- }
- else if((utf8str[i] & 0xF0) == 0xE0 || (utf8str[i] & 0xF8) == 0xF0) i += (utf8str[i] & 0xF0) == 0xE0 ? 3 : 4;
- else i++;
- }
- ansistr[j] = 0;
- return ansistr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement