Posted by Rohan Prabhu on Thu 8 Nov 15:40
report abuse | download | new post
- void createUIF() {
- if(enc_inp == UNICODE_U8) {
- unsigned char u8_hold;
- unsigned char uwrite;
- unsigned char zero = 0;
- while(!(fin.eof())) {
- fin.read((char *) &u8_hold, sizeof(u8_hold));
- if(u8_hold <= 0x7F) {
- uwrite = (int)u8_hold;
- padAndWrite((long)uwrite);
- } else {
- if((u8_hold & 0xF0) == 0xF0) {
- unsigned char b1, b2, b3;
- fin.read((char *) &b1, sizeof(b1));
- fin.read((char *) &b2, sizeof(b2));
- fin.read((char *) &b3, sizeof(b3));
- int write = (long)(((u8_hold & 7)*0x40000) + ((b1 & 63)*0x1000) + ((b2 & 63)*64) + (b3&63));
- padAndWrite((long)write);
- } else if((u8_hold & 0xE0) == 0xE0) {
- unsigned char b1, b2;
- fin.read((char *) &b1, sizeof(b1));
- fin.read((char *) &b2, sizeof(b1));
- int write = (long)(((u8_hold & 15)*4096) + ((b1 & 63)*64) + (b2 & 63));
- padAndWrite((long)write);
- } else if((u8_hold & 0xC0) == 0xC0) {
- unsigned char b1;
- fin.read((char *) &b1, sizeof(b1));
- int write = (long)(((u8_hold & 31)*64) + (b1 & 63));
- padAndWrite((long)write);
- }
- }
- }
- } else if(enc_inp == UNICODE_U16) {
- unsigned short int u16_hold;
- unsigned char b1, b2;
- while(!fin.eof()) {
- u16_hold = u16Read();
- if(fin.eof()) {
- break;
- }
- if((u16_hold < 0xD800) || (u16_hold > 0xDFFF)) {
- padAndWrite(u16_hold);
- } else {
- short int b2;
- short int w1, w2;
- b2 = u16Read();
- w1 = u16_hold & 0x3FF;
- w2 = b2 & 0x3FF;
- int write = (long)(((w1 * 0x400) | w2) + 0x10000);
- padAndWrite((long)write);
- }
- }
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.