比较两个字串的函数
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);
}
* 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);
}
相关文章推荐
- PHP中strncmp()函数比较两个字符串前2个字符是否相等的方法
- javascript 两个字符串比较函数
- 两个比较实用简洁的StringToDate和DateToString方法函数。
- 关于编写函数比较两个整数的大小的问题
- P279_1017 写一函数,实现两个字符串的比较,即自己写一个strcmp函数
- 提供MQL4 中比较实用的两个字符串处理函数
- 编写一个函数模板,可对两个任意格式的数值(包括字符格式)进行比较,返回两者的最小值,同时保证较高的精度。
- c++ 如何用一个函数实现两个字符串的比较
- 编写函数求两个整数 a 和 b 之间的较大值。要求不能使用if, while, switch, for, ?: 以及任何的比较语句
- 两个比较实用简洁的StringToDate和DateToString方法函数。
- 今天下午写两个函数,还是比较通用的~~~
- matlab 同个坐标下的两个函数图像的比较
- 检测变量是否已经设置,并比较Empty 和Isset 两个函数的区别
- 两个参引参出的Get函数比较
- 两个比较有用的Javascript工具函数代码
- TypeScript基础入门 - 类型兼容性 - 比较两个函数
- 编写一个函数比较两个整数大小,但不能使用任何比较操作符
- 写一函数,实现两个字符串的比较。
- @maohoo Oracle两个函数的比较:nvl和nvl2
- 两个比较重要的js函数