⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tstring.h

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 H
字号:
#ifndef _TSTRING_H
#define _TSTRING_H

/* Windows CE SDK does not provide these... */
#ifdef _WIN32_WCE
#ifndef toupper
#define toupper( ch ) \
    (((ch) >= 'a') ? (((ch) - 'a') + 'A') : (ch))
#endif

#ifndef isalpha
#define isalpha( ch ) \
    (((ch) >= 'A' && (ch) <= 'Z') || ((ch) >= 'a' && (ch) <= 'z'))
#endif
#endif /* _WIN32_WCE */

/* Using Unicode characters? */
#ifdef UNICODE

/* Standard library string functions */
#define TSPRINTF wsprintf
#define TSTRCMP(x,y) wcscmp(x,y)
#define TSTRICMP(x,y) _wcsicmp(x,y)
#define TSTRNICMP(x,y,z) _wcsnicmp(x,y,z)
#define TSTRLEN(x) wcslen(x)
#define TSTRCPY(x,y) wcscpy(x,y)
#define TSTRNCPY(x,y,z) wcsncpy(x,y,z)
#define TSTRSTR(x,y) wcsstr(x,y)
#define TSTRCAT(x,y) wcscat(x,y)
#define TSTRTOK(x,y) wcstok(x,y)
#define TSTRCHR(x,y) wcschr(x,y)
#define TTOI(x) _wtoi(x)

/* Convert a Unicode string to ASCII 
   x = buffer for ASCII string
   y = pointer to Unicode string
   z = maximum number of characters to convert (0 specifies use length of y)
*/
#define TSTRTOASCII( x, y, z ) \
{ \
int nLen, i; \
char *p1 = (x); \
const TCHAR *p2 = (y); \
	if ((z) == 0) nLen = TSTRLEN( p2 ); \
	else nLen = (z); \
	for (i = 0; i < nLen && *p2; i++) \
		*p1++ = (char) *p2++; \
	*p1 = '\0'; \
}

/* Convert an ASCII string to Unicode
   x = buffer for Unicode string
   y = pointer to ASCII string
   z = maximum number of characters to convert (0 specifies use length of y)
*/
#define ASCIITOTSTR( x, y, z ) \
{ \
int nLen, i; \
TCHAR *p1 = (x); \
const char *p2 = (y); \
	if ((z) == 0) nLen = strlen( p2 ); \
	else nLen = (z); \
	for (i = 0; i < nLen && *p2; i++) \
		*p1++ = (TCHAR) *p2++; \
	*p1 = (TCHAR) '\0'; \
}

/* Not using Unicode characters */
#else

/* Standard library string functions */
#define TSPRINTF sprintf
#define TSTRCMP(x,y) strcmp(x,y)
#define TSTRICMP(x,y) _stricmp(x,y)
#define TSTRNICMP(x,y,z) _strnicmp(x,y,z)
#define TSTRLEN(x) strlen(x)
#define TSTRCPY(x,y) strcpy(x,y)
#define TSTRNCPY(x,y,z) strncpy(x,y,z)
#define TSTRSTR(x,y) strstr(x,y)
#define TSTRCAT(x,y) strcat(x,y)
#define TSTRTOK(x,y) strtok(x,y)
#define TSTRCHR(x,y) strchr(x,y)
#define TTOI(x) atoi(x)

/* Dummy conversions */
#define TSTRTOASCII( x, y, z ) \
{ \
	if ((z) == 0) strcpy( x, y ); \
	else strncpy( x, y, z ); \
}

#define ASCIITOTSTR( x, y, z ) \
{ \
	if ((z) == 0) strcpy( x, y ); \
	else strncpy( x, y, z ); \
}

#endif /* UNICODE */

#endif /* _TSTRING_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -