kestutis

UTF-8

Apr 9th, 2013
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main() {
  4.     unsigned char a[] = "Ąąa";
  5.     //Kaip atrodo šešioliktainėje Ą=c4 84 ą=c4 85 a=61
  6.     //UTF-8 simbolių lentelė su šešioliktainiais kodais: http://www.utf8-zeichentabelle.de/unicode-utf8-table.pl?number=1024&htmlent=1
  7.     unsigned int i=0, length=strlen(a);
  8.     char found=0;
  9.     //printf("%x", 'a');//Išvedimas šešioliktainiu kodu
  10.     while(i<length) {
  11.         if(found) {
  12.             if(a[i] == 0x84) puts("Lietuviška A didžioji raidė");
  13.             else if(a[i] == 0x85) puts("Lietuviška a mažoji raidė");
  14.             found=0;
  15.         } else {
  16.             if(a[i] == 0xC4) found = 1;
  17.             else if(a[i] == 0x61) puts("paprasta a mažoji raidė");
  18.         }
  19.         i++;
  20.     }
  21.     return 0;
  22. }
  23. ================
  24. Programa išveda:
  25. ================
  26. Lietuviška A didžioji raidė
  27. Lietuviška a mažoji raidė
  28. paprasta a mažoji raidė
Advertisement
Add Comment
Please, Sign In to add comment