pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

knowingunicode private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Rohan Prabhu on Thu 8 Nov 15:40
report abuse | download | new post

  1. void createUIF() {
  2.     if(enc_inp == UNICODE_U8) {
  3.         unsigned char u8_hold;
  4.         unsigned char uwrite;
  5.         unsigned char zero = 0;
  6.        
  7.         while(!(fin.eof())) {        
  8.             fin.read((char *) &u8_hold, sizeof(u8_hold));
  9.             if(u8_hold <= 0x7F) {
  10.                 uwrite = (int)u8_hold;
  11.                 padAndWrite((long)uwrite);
  12.             } else {
  13.                 if((u8_hold & 0xF0) == 0xF0) {
  14.                     unsigned char b1, b2, b3;
  15.                     fin.read((char *) &b1, sizeof(b1));
  16.                     fin.read((char *) &b2, sizeof(b2));
  17.                     fin.read((char *) &b3, sizeof(b3));
  18.                    
  19.                     int write = (long)(((u8_hold & 7)*0x40000) + ((b1 & 63)*0x1000) + ((b2 & 63)*64) + (b3&63));
  20.                     padAndWrite((long)write);
  21.                 } else if((u8_hold & 0xE0) == 0xE0) {
  22.                     unsigned char b1, b2;
  23.                     fin.read((char *) &b1, sizeof(b1));
  24.                     fin.read((char *) &b2, sizeof(b1));
  25.                    
  26.                     int write = (long)(((u8_hold & 15)*4096) + ((b1 & 63)*64) + (b2 & 63));
  27.                     padAndWrite((long)write);
  28.                 } else if((u8_hold & 0xC0) == 0xC0) {
  29.                     unsigned char b1;
  30.                     fin.read((char *) &b1, sizeof(b1));
  31.                    
  32.                     int write = (long)(((u8_hold & 31)*64) + (b1 & 63));
  33.                     padAndWrite((long)write);
  34.                 }
  35.             }
  36.         }
  37.     } else if(enc_inp == UNICODE_U16) {
  38.         unsigned short int u16_hold;
  39.         unsigned char b1, b2;
  40.        
  41.         while(!fin.eof()) {
  42.             u16_hold = u16Read();
  43.            
  44.             if(fin.eof()) {
  45.                 break;
  46.             }
  47.            
  48.             if((u16_hold < 0xD800) || (u16_hold > 0xDFFF)) {
  49.                 padAndWrite(u16_hold);
  50.             } else {
  51.                 short int b2;
  52.                 short int w1, w2;
  53.                
  54.                 b2 = u16Read();
  55.                 w1 = u16_hold & 0x3FF;
  56.                 w2 = b2 & 0x3FF;
  57.                
  58.                 int write = (long)(((w1 * 0x400) | w2) + 0x10000);
  59.                 padAndWrite((long)write);
  60.             }
  61.         }
  62.     }
  63. }

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.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me