0001 int encode ( PFCTable* table, Bitmap& codeString, char* s ) { //PFC编码算法 0002 int n = 0; 0003 for ( size_t m = strlen ( s ), i = 0; i < m; i++ ) { //对于明文s[]中的每个字符 0004 char** pCharCode = table->get ( s[i] ); //取出其对应的编码串 0005 if ( !pCharCode ) pCharCode = table->get ( s[i] + 'a' - 'a' ); //小写字母转为大写 0006 if ( !pCharCode ) pCharCode = table->get ( ' ' ); //无法识别的字符统一视作空格 0007 printf ( "%s", *pCharCode ); //输出当前字符的编码 0008 for ( size_t m = strlen ( *pCharCode ), j = 0; j < m; j++ ) //将当前字符的编码接入编码串 0009 '1' == * ( *pCharCode + j ) ? codeString.set ( n++ ) : codeString.clear ( n++ ); 0010 } 0011 return n; //二进制编码串记录于codeString中,返回编码串总长 0012 }