#include <defs.h>
#include <sysdata.h>
#include <swbuf.h>
Go to the source code of this file.
Definition at line 207 of file utilstr.cpp.
210 const unsigned char *b = (
const unsigned char *)myCopy.
c_str();
211 const unsigned char *q = 0;
212 bool invalidChar =
false;
219 for (
long start = q - (
const unsigned char *)myCopy.
c_str(); len; len--) {
220 myCopy[start+len-1] = 0x1a;
const char * c_str() const
SW_u32 getUniCharFromUTF8(const unsigned char **buf, bool skipValidation=false)
SW_u32 getUniCharFromUTF8 |
( |
const unsigned char ** |
buf, |
|
|
bool |
skipValidation = false |
|
) |
| |
|
inline |
Definition at line 88 of file utilstr.h.
104 if ((**buf >> 6) == 2) {
112 if ((**buf & 32) == 0) { subsequent = 1; }
113 else if ((**buf & 16) == 0) { subsequent = 2; }
114 else if ((**buf & 8) == 0) { subsequent = 3; }
115 else if ((**buf & 4) == 0) { subsequent = 4; }
116 else if ((**buf & 2) == 0) { subsequent = 5; }
117 else if ((**buf & 1) == 0) { subsequent = 6; }
120 ch = **buf & (0xFF>>(subsequent + 1));
122 for (
int i = 1; i <= subsequent; ++i) {
126 if (((*buf)[i] >> 6) != 2) {
131 ch |= (*buf)[i] & 63;
133 *buf += (subsequent+1);
135 if (!skipValidation) {
137 if (subsequent > 3) ch = 0;
139 if (ch > 0x1FFFFF) ch = 0;
141 if (ch > 0x10FFFF) ch = 0;
143 if (ch < 0x80 && subsequent > 0) ch = 0;
144 if (ch < 0x800 && subsequent > 1) ch = 0;
145 if (ch < 0x10000 && subsequent > 2) ch = 0;
146 if (ch < 0x200000 && subsequent > 3) ch = 0;
Definition at line 165 of file utilstr.h.
166 unsigned long base = appendTo->
size();
169 if (uchar > 0x10FFFF) uchar = 0xFFFD;
170 char bytes = uchar < 0x80 ? 1 : uchar < 0x800 ? 2 : uchar < 0x10000 ? 3 : 4;
174 (*appendTo)[
base ] = (
unsigned char)uchar;
177 (*appendTo)[base+1] = (
unsigned char)(0x80 | (uchar & 0x3f));
179 (*appendTo)[
base ] = (
unsigned char)(0xc0 | (uchar & 0x1f));
182 (*appendTo)[base+2] = (
unsigned char)(0x80 | (uchar & 0x3f));
184 (*appendTo)[base+1] = (
unsigned char)(0x80 | (uchar & 0x3f));
186 (*appendTo)[
base ] = (
unsigned char)(0xe0 | (uchar & 0x0f));
189 (*appendTo)[base+3] = (
unsigned char)(0x80 | (uchar & 0x3f));
191 (*appendTo)[base+2] = (
unsigned char)(0x80 | (uchar & 0x3f));
193 (*appendTo)[base+1] = (
unsigned char)(0x80 | (uchar & 0x3f));
195 (*appendTo)[
base ] = (
unsigned char)(0xf0 | (uchar & 0x07));
unsigned long size() const
void setSize(unsigned long len)
Definition at line 44 of file utilstr.h.
48 int len = (int)strlen(istr) + 1;
49 *ipstr =
new char [ len * memPadFactor ];
50 memcpy(*ipstr, istr, len);
Definition at line 194 of file utilstr.cpp.
195 #if defined(__GNUC__)
196 return ::strcasecmp(s1, s2);
198 #if defined(_WIN32_WCE)
199 return ::_stricmp(s1, s2);
int stricmp(const char *s1, const char *s2)
Definition at line 145 of file utilstr.cpp.
146 int tLen = (int)strlen(s2);
147 int cLen = (int)strlen(s1);
148 char *target =
new char [ tLen + 1 ];
150 const char *retVal = 0;
153 for (i = 0; i < tLen; i++)
156 for (i = 0; i < (cLen - tLen)+1; i++) {
157 if (
SW_toupper(s1[i]) == (
unsigned char)*target) {
158 for (j = 1; j < tLen; j++) {
159 if (
SW_toupper(s1[i+j]) != (
unsigned char)target[j])
Definition at line 180 of file utilstr.cpp.
181 int tLen = (int)strlen(s2);
182 int cLen = (int)strlen(s1);
185 for (i = 0; ((i < len) && (i < tLen) && (i < cLen)); i++) {
191 return (i < len) ? cLen - tLen : 0;
Definition at line 118 of file utilstr.cpp.
122 int len = (int)strlen(istr);
125 rtmp = istr + (len - 1);
127 while ((rtmp > istr)&&((*rtmp ==
' ')||(*rtmp ==
'\t')||(*rtmp == 10)||(*rtmp == 13))) *(rtmp--) = 0;
128 while ((*tmp ==
' ')||(*tmp ==
'\t')||(*tmp == 10)||(*tmp == 13)) tmp++;
129 memmove(istr, tmp, (rtmp - tmp) + 1);
130 istr[(rtmp - tmp) + 1] = 0;
Definition at line 239 of file utilstr.cpp.
250 wcharBuf.
append((
wchar_t)0x1a);
SWBuf & append(const char *str, long max=-1)
SW_u32 getUniCharFromUTF8(const unsigned char **buf, bool skipValidation=false)
Definition at line 263 of file utilstr.cpp.
SWBuf * getUTF8FromUniChar(SW_u32 uchar, SWBuf *appendTo)
const unsigned char SW_tolower_array[256] |
const unsigned char SW_toupper_array[256] |