U16 mmi_sms_char_towupper(U16 wChar)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((wChar >= 0xe0 && wChar <= 0xf6) || (wChar >= 0xf8 && wChar <= 0xfe) ||
(wChar >= 0x0430 && wChar <= 0x044f) || (wChar >= 0x03B1 && wChar <= 0x03C1) || (wChar >= 0x03C3 && wChar <= 0x03CA))
{
return (wChar - 0x20);
}
else if (wChar == 0x0103 || wChar == 0x01A1 || wChar == 0x01B0 || wChar == 0x0188 || wChar == 0x018C || wChar == 0x0192 ||
wChar == 0x01AC || wChar == 0x01B9 || wChar == 0x01F3)
{
return (wChar - 1);
}
else if (wChar >= 0x0450 && wChar <= 0x045f)
{
return (wChar - 0x50);
}
else if (wChar == 0x0491)
{
return 0x0490;
}
else if (wChar >= 0x0100 && wChar <= 0x0137 || wChar >= 0x0182 && wChar <= 0x0185 ||
wChar >= 0x0198 && wChar <= 0x01A5 || wChar >= 0x01DE && wChar <= 0x01EF ||
wChar >= 0x01F8 && wChar <= 0x01FF || wChar >= 0x0222 && wChar <= 0x0233)
{
if ((wChar & 1) == 1) /* odd is small case */
return wChar - 1;
else
return wChar;
}
else if (wChar >= 0x0139 && wChar <= 0x0148 || wChar >= 0x014A && wChar <=0x0177 || wChar >= 0x0179 && wChar <=0x017E ||
wChar >= 0x01B3 && wChar <= 0x01B6 || wChar >= 0x02CD && wChar <= 0x01DC)
{
if ((wChar & 1) == 0) /* even is small case */
return wChar - 1;
else
return wChar;
}
else
{
return wChar;
}
}
S32 mmi_sms_compare_chars(U16 char1, U16 char2)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 char1_upper = mmi_sms_char_towupper(char1);
U16 char2_upper = mmi_sms_char_towupper(char2);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* try UCS2 matching */
if (char1 == char2 || char1_upper == char2_upper)
{
return 0;
}
/* no match */
return char1 - char2;
}
void mmi_sms_compare_ucs2_strings(S8 *string1, S8 *string2, U8 *same_count, S32 *distance)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U8 len1, len2;
U8 max_len, min_len;
U8 i;
U16 code1, code2;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
*same_count = 0;
*distance = 0;
len1 = (U8) mmi_ucs2strlen(string1);
len2 = (U8) mmi_ucs2strlen(string2);
if (len1 > len2)
{
max_len = len1;
min_len = len2;
}
else
{
max_len = len2;
min_len = len1;
}
for (i = 0; i < max_len && i < 60; i++) /* Use Max Phonebook Strlen as upper bound */
/* for (i = 0; i < max_len; i++) */
{
/* If all characters are identical from 0 to min_len. */
if (i >= min_len)
{
/* First is greater than second */
if (len1 > len2)
{
*distance = (U16) string1[i * ENCODING_LENGTH];
}
/* First and second is congruence */
else if (len1 == len2)
{
*distance = 0;
}
/* len1 < len2: First is less than second */
else
{
*distance = -(U16) string2[i * ENCODING_LENGTH];
}
//if (min_len == 0)
// *distance = - *distance;
break;
}
/* First, compare from 0 to min_len */
else
{
memcpy(&code1, (string1 + i * ENCODING_LENGTH), 2);
memcpy(&code2, (string2 + i * ENCODING_LENGTH), 2);
if ((*distance = mmi_sms_compare_chars(code1, code2)) == 0)
{
*same_count = *same_count + 1;
}
/* First and second is not equal, return distance */
else
{
break;
}
}
}
}
CHAR *mmi_ucs2ncpy(CHAR *strDestination, const CHAR *strSource, U32 size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* On the Target */
return (CHAR *)app_ucs2_strncpy(
(kal_int8*)strDestination,
(const kal_int8*)strSource,
(kal_uint32)size);
}
pBOOL SmsGetNewMsgContent(const S8 * sms_data)
{
U8 buf[10];
S32 len =0;
U8 tem[612];
U8 Str[(70+1)*ENCODING_LENGTH] ;
U8 *SmsContent;
S16 pError;
U16 filter_str_len = 0;
U16 sms_str_len = 0;
int i = 0;
U8 same_count;
S32 distance;
S8* desContent[20];
memset(tem,0,sizeof(tem));
mmi_ucs2cpy(desContent,GetString(STR_QQHM_SOS_CONTINUE));
filter_str_len = mmi_ucs2strlen((const S8 *)desContent);
sms_str_len = mmi_ucs2strlen((const S8 *)sms_data);
if((filter_str_len == 0)||(sms_str_len == 0))
{
return FALSE;
}
SmsContent = (U8 *)sms_data;
for( ;i < sms_str_len; i++ )
{
mmi_ucs2ncpy((S8 *)Str, (const S8 *)SmsContent, filter_str_len);
mmi_sms_compare_ucs2_strings((S8 *)Str, (S8 *)desContent, &same_count, &distance);
SmsContent += 2;
if( same_count == filter_str_len)
{
return TRUE;
}
}
return FALSE;
}
中文比较问题
最新推荐文章于 2023-12-15 09:42:44 发布