📄 strutils.c
字号:
#ifdef __cplusplus
extern "C" {
#endif
/*
NOTICE:
This document contains information that is proprietary to RADVISION LTD.
No part of this publication may be reproduced in any form whatsoever without
written prior approval by RADVISION LTD.
RADVISION LTD reserves the right to revise this publication and make changes
without obligation to notify any person of such revisions or changes.
*/
/****************************************************************************
strutils.c -- String Utilities
Module Authors: Oz Solomonovich, Sasha Ruditsky
This Comment: 1-Jan-1997
Abstract: Various string manipulation utilities.
Platforms: All.
Known Bugs: None.
****************************************************************************/
#include "rvstdio.h"
#include <ctype.h>
#include "strutils.h"
int chrn2bmp(RvChar *str, RvSize_t maxStrLen, RvUint8* bmpStr)
{
RvSize_t i, i2;
for (i = 0, i2 = 0; i < maxStrLen; i++, i2 += 2)
{
bmpStr[i2 + 0] = 0;
bmpStr[i2 + 1] = str[i];
}
return i2;
}
int chr2bmp(RvChar *str, RvUint8* bmpStr)
{
RvSize_t len = strlen(str);
return chrn2bmp(str, len, bmpStr);
}
int bmp2chr(RvChar *str, RvUint8* bmpStr, RvSize_t bmpLen)
{
RvSize_t i, i2;
for (i = 0, i2 = 0; i < bmpLen/2; i++, i2 += 2)
{
if (bmpStr[i2])
return RV_ERROR_UNKNOWN;
str[i] = bmpStr[i2 + 1];
}
str[i] = 0;
return 0;
}
/* case insensitive strncmp */
int strncmp_ci(const RvChar *dst, const RvChar *src, RvSize_t count)
{
int f, l;
int result = 0;
if (count)
{
do
{
f = tolower(*dst);
l = tolower(*src);
dst++;
src++;
} while (--count && f && l && f == l);
result = f - l;
}
return(result);
}
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -