Portál AbcLinuxu, 13. května 2025 19:18
#define TO_UNICODE(c1, c2) ((Uint16)(((unsigned char)c1)&0x1F) << 6 | (Uint16)(((unsigned char)c2)&0x3F))ale asi nakoniec tie znaky nechám v unicode a upravím pár funkcií na prácu s nimi, bude to rýchlejšie...
#include <stdio.h> #define FROM_UNICODE(c, c1, c2, c3) \ if ((Uint16)(c) <= 0x7f) { \ c1 = (unsigned char)(c); \ c2 = c3 = 0; \ } else if ((Uint16)(c) <= 0x7ff) { \ c1=(unsigned char)(((c) >> 6) | 0xc0); \ c2=(unsigned char)(((c) & 0x3f) | 0x80); \ c3 = 0; \ } else if ((Uint16)(c) <= 0xd7ff) { \ c1=(unsigned char)(((c) >> 12) | 0xe0); \ c1=(unsigned char)((((c) >> 6) & 0x3f) | 0x80); \ c3=(unsigned char)(((c) & 0x3f) | 0x80); \ } else { \ c1 = c2 = c3 = 0; \ } typedef unsigned short int Uint16; int main(void) { Uint16 z = 0xfd; unsigned char c1, c2, c3; FROM_UNICODE(z, c1, c2, c3); printf("%x, %x %x %x\n", z, c1, c2, c3); return 0; }Ja by som tam pravdepodobne používal originálne dáta v UCS-2 alebo v UTF-16 (alebo čo sa to tam vlastne používa).
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.