您的位置:首页 > 其它

比较两个字串的函数

2009-11-04 15:32 211 查看
/*****************************************************************************
* FUNCTION
* mmi_wcscmp
* DESCRIPTION
* Compares two UCS2 encoded strings(wide-character) and returns an integer to
* indicate whether the destination string is less than the source string,
* the two are equal, or whether the destination string is greater than the
* source string.
* PARAMETERS
* str_src [IN] UCS2 encoded destination string(wide-character) for
* left-hand side of comparison.
* str_dst [IN] UCS2 encoded source string(wide-character) for right-hand
* side of comparison.
* RETURNS
* returns <0 if str_src < str_dst
* returns 0 if str_src == str_dst
* returns >0 if str_src > str_dst
*****************************************************************************/
S32 mmi_wcscmp(const U16 *str_src, const U16 *str_dst)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/

/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return (S32) app_ucs2_wcscmp((const kal_wchar *)str_src, (const kal_wchar *)str_dst);
}

kal_int32 app_ucs2_wcscmp(const kal_wchar *str_src, const kal_wchar *str_dst)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/

/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while((*str_src == *str_dst) && *str_src)
{
++str_src, ++str_dst;
}

return (kal_int32)(*str_src - *str_dst);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: