比较两个字串的函数

 /*****************************************************************************
 * 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);
}

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值