示例#1
0
int ZGui::checkCodec(char* chars, int len, int codeId)
{
	if ( codeId == 7 ) //if big5 codec
		return big5HeuristicContentMatch( chars, len );
	
    QTextCodec* codec = codecByLocalId(codeId);
    
    if ( !codec ) { printf("Error: Codec %d not found!!",codeId); return -1; };
    
    int col = codec->heuristicContentMatch(chars,len);
    
    if ( codeId > 0 )
    	if ( len != strlen(chars) )
    		if ( col )
    			col--;
    		
    return col;
}
int UtilsCode::checkCodec(char* chars, int len, int codeId)
{
	//cout<<"==== checkCodec "<<endl;
	
	if ( codeId == 8 ) //if big5 codec
		return big5HeuristicContentMatch( chars, len );
	
    QTextCodec* codec = codecByLocalId(codeId);
    
    if ( !codec ) { 
		printf("Error: Codec %d not found!!", codeId);
		return -1; 
	}
    
    int col = codec->heuristicContentMatch(chars,len);
    
    if ( codeId > 0 ) {
    	if ( len != strlen(chars) ) {
    		if ( col )
    			col--;
		}		
    }		
    return col;
}