charconvfw/charconvplugins/src/plugins/big5.cpp
branchRCL_3
changeset 9 26914f8d1faf
parent 0 1fb32624e06b
equal deleted inserted replaced
7:1799ab513ec3 9:26914f8d1faf
    95 	TInt totalWeight=0;		//sum of the weights of 20 most frequent chars
    95 	TInt totalWeight=0;		//sum of the weights of 20 most frequent chars
    96 	TInt sumOfGoodChar=0;		//the number of chars whose first byte and second are both in the range
    96 	TInt sumOfGoodChar=0;		//the number of chars whose first byte and second are both in the range
    97 	TInt sumOfWeight=0;		//sum of the weights of the chars which are included in the sample
    97 	TInt sumOfWeight=0;		//sum of the weights of the chars which are included in the sample
    98 	TInt sumOutChar=0;		//the number of chars which are not common
    98 	TInt sumOutChar=0;		//the number of chars which are not common
    99 	TInt sumOfBadSecondByte=0;//the number of chars whose first byte is in the range but not the second
    99 	TInt sumOfBadSecondByte=0;//the number of chars whose first byte is in the range but not the second
       
   100 	TInt sumOfBadSingleByte=0;	//the number of bad single byte, which is not in valid range
   100 	struct referenceChar
   101 	struct referenceChar
   101 		{
   102 		{
   102 		TUint charBig5;
   103 		TUint charBig5;
   103 		TInt weight;
   104 		TInt weight;
   104 		};
   105 		};
   154 			else
   155 			else
   155 				{
   156 				{
   156 				sumOfBadSecondByte++;
   157 				sumOfBadSecondByte++;
   157 				}
   158 				}
   158 			}
   159 			}
       
   160 		// if seldom used characters
       
   161 		else if (aSample[i] < 0x20 || aSample[i] > 0x7F ) 
       
   162 			{
       
   163 			if (aSample[i]!=0x09 && aSample[i]!=0x0A && aSample[i]!=0x0D)
       
   164 				sumOfBadSingleByte++;
       
   165 			}
   159 		} // for 
   166 		} // for 
   160 
   167 
   161 	if (sumOfGoodChar)
   168 	if (sumOfGoodChar)
   162 		{
   169 		{
   163 		aConfidenceLevel=sumOfGoodChar*100/(sumOfBadSecondByte+sumOfGoodChar);
   170 		aConfidenceLevel=sumOfGoodChar*100/(sumOfBadSecondByte+sumOfGoodChar+sumOfBadSingleByte);
   164 		aConfidenceLevel=aConfidenceLevel-Max(0,((totalWeight-sumOfWeight)*sumOfGoodChar/1000));//against frequent chars 
   171 		aConfidenceLevel=aConfidenceLevel-Max(0,((totalWeight-sumOfWeight)*sumOfGoodChar/1000));//against frequent chars 
   165 		aConfidenceLevel=aConfidenceLevel-sumOutChar*100/sumOfGoodChar;//against gap
   172 		aConfidenceLevel=aConfidenceLevel-sumOutChar*100/sumOfGoodChar;//against gap
   166 		aConfidenceLevel=(aConfidenceLevel < 0)?0:aConfidenceLevel;
   173 		aConfidenceLevel=(aConfidenceLevel < 0)?0:aConfidenceLevel;
   167 		}
   174 		}
   168 	else
   175 	else