0001 int encode(HuffTable& table, Bitmap& codeString, char* s) { //按照编码表对Bitmap串编码 0002 int n = 0; //待返回的编码串总长n 0003 for (size_t m = strlen(s), i = 0; i < m; i++) //对明文中的 0004 if ((0x20 <= s[i]) && (s[i] < 0x7F)) { //每个字母 0005 Entry<char, char*>* c = table.get(s[i]); //取出其对应的编码串 0006 printf("%s", c->value); //输出当前字符的编码 0007 for (size_t m = strlen(c->value), j = 0; j < m; j++) //将当前字符的编码接入编码串 0008 '1' == c->value[j] ? codeString.set(n++) : codeString.clear(n++); 0009 } 0010 printf("\n"); return n; 0011 } //二进制编码串记录于位图codeString中