📄 app_str.c
字号:
}
string1 += 2;
string2 += 2;
count += 2;
}
return 0;
}
/* End MTK: Tim */
/*****************************************************************************
* FUNCTION
* app_ucs2_strncpy
* DESCRIPTION
* copies the one UCS2 encoded string to other
*
* In size pass no of characters not bytes
* PARAMETERS
* strDestination [?]
* strSource [IN]
* size [IN]
* strDest(?) [OUT] > Destination array
* strSrc(?) [IN] > Source Array
* RETURNS
* kal_int8* -> pointer to destination string or NULL
*****************************************************************************/
kal_int8 *app_ucs2_strncpy(kal_int8 *strDestination, const kal_int8 *strSource, kal_uint32 size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint16 count = 1;
kal_uint32 count1 = 0;
kal_int8 *temp = strDestination;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
size = size * 2;
/* MMI_ASSERT(!(strDestination == NULL)); */
while (!((*(strSource + count) == 0) && (*(strSource + count - 1) == 0)) && (count1 < size))
{
*(strDestination + count - 1) = *(strSource + count - 1);
*(strDestination + count) = *(strSource + count);
count += 2;
count1 += 2;
}
*(strDestination + count - 1) = '\0';
*(strDestination + count) = '\0';
return temp;
}
/*****************************************************************************
* FUNCTION
* app_ucs2_strcat
* DESCRIPTION
*
*
* User has to ensure that enough space is
* available in destination
* PARAMETERS
* strDestination [?]
* strSource [IN]
* RETURNS
* kal_int8
*****************************************************************************/
kal_int8 *app_ucs2_strcat(kal_int8 *strDestination, const kal_int8 *strSource)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int8 *dest = strDestination;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
dest = dest + app_ucs2_strlen(strDestination) * ENCODING_LENGTH;
app_ucs2_strcpy(dest, strSource);
return strDestination;
}
/*****************************************************************************
* FUNCTION
* app_ucs2_strncat
* DESCRIPTION
*
*
* User has to ensure that enough space is
* available in destination
* PARAMETERS
* strDestination [?]
* strSource [IN]
* size [IN]
* RETURNS
* kal_int8
*****************************************************************************/
kal_int8 *app_ucs2_strncat(kal_int8 *strDestination, const kal_int8 *strSource, kal_uint32 size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int8 *dest = strDestination;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
dest = dest + app_ucs2_strlen(strDestination) * ENCODING_LENGTH;
app_ucs2_strncpy(dest, strSource, size);
return strDestination;
}
/*****************************************************************************
* FUNCTION
* app_ucs2str_appendchar
* DESCRIPTION
*
*
* User has to ensure that enough space is
* available in destination
* PARAMETERS
* strDestination [?]
* ch [IN]
* RETURNS
* kal_int8
*****************************************************************************/
kal_int8 *app_ucs2str_appendchar(kal_int8 *strDestination, kal_uint16 ch)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int8 *dest = strDestination;
kal_uint16 buffer[2];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
dest = dest + app_ucs2_strlen(strDestination) * ENCODING_LENGTH;
buffer[0] = ch;
buffer[1] = 0;
app_ucs2_strcpy(dest, (const kal_int8*)buffer);
return strDestination;
}
/*****************************************************************************
* FUNCTION
* app_ucs2str_n_appendchar
* DESCRIPTION
*
*
* User has to ensure that enough space is
* available in destination
* PARAMETERS
* strDestination [?]
* ch [IN]
* size [IN]
* RETURNS
* kal_int8
*****************************************************************************/
kal_int8 *app_ucs2str_n_appendchar(kal_int8 *strDestination, kal_uint16 ch, kal_uint32 size)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int8 *dest = strDestination;
kal_uint16 buffer[2];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
dest = dest + app_ucs2_strlen(strDestination) * ENCODING_LENGTH;
buffer[0] = ch;
buffer[1] = 0;
app_ucs2_strncpy(dest, (const kal_int8*)buffer, size);
return strDestination;
}
/*****************************************************************************
* FUNCTION
* app_ansii_to_unicodestring
* DESCRIPTION
* Converts Ansii encode string to unicode
*
* Caller has to ensure that pOutBuffer
* should be as large
* PARAMETERS
* pOutBuffer [?]
* pInBuffer [?]
* RETURNS
* kal_uint16
*****************************************************************************/
kal_uint16 app_ansii_to_unicodestring(kal_int8 *pOutBuffer, kal_int8 *pInBuffer)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int16 count = -1;
kal_uint8 charLen = 0;
kal_uint8 arrOut[2];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while (*pInBuffer != '\0')
{
app_unicode_to_ucs2encoding((kal_uint16) * pInBuffer, &charLen, arrOut);
// #ifdef MMI_ON_WIN32
pOutBuffer[++count] = arrOut[0];
pOutBuffer[++count] = arrOut[1];
pInBuffer++;
// #endif
#ifdef __FOR_TESTING /* MMI_ON_HARDWARE_P */
pOutBuffer[++count] = arrOut[1]; /* arrOut[0]; */
pOutBuffer[++count] = arrOut[0]; /* arrOut[1]; */
pInBuffer++;
#endif /* __FOR_TESTING */
}
pOutBuffer[++count] = '\0';
pOutBuffer[++count] = '\0';
return count + 1;
}
/*****************************************************************************
* FUNCTION
* app_ansii_n_to_unicodestring
* DESCRIPTION
* Converts N character Ansii encode string to unicode
*
* Caller has to ensure that pOutBuffer
* should be as large
* PARAMETERS
* pOutBuffer [?]
* pInBuffer [?]
* len [IN]
* RETURNS
* kal_uint16
*****************************************************************************/
kal_uint16 app_ansii_n_to_unicodestring(kal_int8 *pOutBuffer, kal_int8 *pInBuffer, kal_uint32 len)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int16 count = -1;
kal_uint8 charLen = 0;
kal_uint8 arrOut[2];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while (len)
{
app_unicode_to_ucs2encoding((kal_uint16) * pInBuffer, &charLen, arrOut);
// #ifdef MMI_ON_WIN32
pOutBuffer[++count] = arrOut[0];
pOutBuffer[++count] = arrOut[1];
pInBuffer++;
// #endif
#ifdef __FOR_TESTING /* MMI_ON_HARDWARE_P */
pOutBuffer[++count] = arrOut[1]; /* arrOut[0]; */
pOutBuffer[++count] = arrOut[0]; /* arrOut[1]; */
pInBuffer++;
#endif /* __FOR_TESTING */
len--;
}
return count + 1;
}
/*****************************************************************************
* FUNCTION
* app_unicode_to_ansii
* DESCRIPTION
* Converts Unicode encode string to Ascii
*
* Caller has to ensure that pOutBuffer
* should be large enough
* PARAMETERS
* pOutBuffer [?]
* pInBuffer [?]
* RETURNS
* kal_uint16
*****************************************************************************/
kal_uint16 app_unicode_to_ansii(kal_int8 *pOutBuffer, kal_int8 *pInBuffer)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint16 count = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while (!((*pInBuffer == 0) && (*(pInBuffer + 1) == 0)))
{
*pOutBuffer = *(pInBuffer);
#ifdef __FOR_TESTING /* MMI_ON_HARDWARE_P */
*pOutBuffer = *(pInBuffer + 1);
#endif
pInBuffer += 2;
pOutBuffer++;
count++;
}
*pOutBuffer = 0;
return count;
}
/*****************************************************************************
* FUNCTION
* app_unicode_n_to_ansii
* DESCRIPTION
* Converts N character Unicode encode string to Ascii
*
* Caller has to ensure that pOutBuffer
* should be large enough
* PARAMETERS
* pOutBuffer [?]
* pInBuffer [?]
* len [IN]
* RETURNS
* kal_uint16
*****************************************************************************/
kal_uint16 app_unicode_n_to_ansii(kal_int8 *pOutBuffer, kal_int8 *pInBuffer, kal_uint32 len)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint16 count = 0;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while ((len) && (!((*pInBuffer == 0) && (*(pInBuffer + 1) == 0))))
{
*pOutBuffer = *(pInBuffer);
#ifdef __FOR_TESTING /* MMI_ON_HARDWARE_P */
*pOutBuffer = *(pInBuffer + 1);
#endif
pInBuffer += 2;
pOutBuffer++;
count++;
len -= 2;
}
return count;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -