OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <stddef.h> // For offsetof(). | 7 #include <stddef.h> // For offsetof(). |
8 #include <cctype> | 8 #include <cctype> |
9 | 9 |
10 #include "core/include/fxcrt/fx_basic.h" | 10 #include "core/include/fxcrt/fx_basic.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 void* pData = FX_Alloc(uint8_t, totalSize); | 37 void* pData = FX_Alloc(uint8_t, totalSize); |
38 return new (pData) StringData(nLen, usableLen); | 38 return new (pData) StringData(nLen, usableLen); |
39 } | 39 } |
40 CFX_WideString::~CFX_WideString() { | 40 CFX_WideString::~CFX_WideString() { |
41 if (m_pData) { | 41 if (m_pData) { |
42 m_pData->Release(); | 42 m_pData->Release(); |
43 } | 43 } |
44 } | 44 } |
45 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) { | 45 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) { |
46 if (stringSrc.m_pData == NULL) { | 46 if (!stringSrc.m_pData) { |
47 m_pData = NULL; | 47 m_pData = NULL; |
48 return; | 48 return; |
49 } | 49 } |
50 if (stringSrc.m_pData->m_nRefs >= 0) { | 50 if (stringSrc.m_pData->m_nRefs >= 0) { |
51 m_pData = stringSrc.m_pData; | 51 m_pData = stringSrc.m_pData; |
52 m_pData->Retain(); | 52 m_pData->Retain(); |
53 } else { | 53 } else { |
54 m_pData = NULL; | 54 m_pData = NULL; |
55 *this = stringSrc; | 55 *this = stringSrc; |
56 } | 56 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 } | 94 } |
95 m_pData = StringData::Create(nNewLen); | 95 m_pData = StringData::Create(nNewLen); |
96 if (m_pData) { | 96 if (m_pData) { |
97 FXSYS_memcpy(m_pData->m_String, str1.GetPtr(), | 97 FXSYS_memcpy(m_pData->m_String, str1.GetPtr(), |
98 str1.GetLength() * sizeof(FX_WCHAR)); | 98 str1.GetLength() * sizeof(FX_WCHAR)); |
99 FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.GetPtr(), | 99 FXSYS_memcpy(m_pData->m_String + str1.GetLength(), str2.GetPtr(), |
100 str2.GetLength() * sizeof(FX_WCHAR)); | 100 str2.GetLength() * sizeof(FX_WCHAR)); |
101 } | 101 } |
102 } | 102 } |
103 void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) { | 103 void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) { |
104 if (m_pData == NULL) { | 104 if (!m_pData) { |
105 return; | 105 return; |
106 } | 106 } |
107 CopyBeforeWrite(); | 107 CopyBeforeWrite(); |
108 if (nNewLength == -1) { | 108 if (nNewLength == -1) { |
109 nNewLength = m_pData ? FXSYS_wcslen(m_pData->m_String) : 0; | 109 nNewLength = m_pData ? FXSYS_wcslen(m_pData->m_String) : 0; |
110 } | 110 } |
111 if (nNewLength == 0) { | 111 if (nNewLength == 0) { |
112 Empty(); | 112 Empty(); |
113 return; | 113 return; |
114 } | 114 } |
115 FXSYS_assert(nNewLength <= m_pData->m_nAllocLength); | 115 FXSYS_assert(nNewLength <= m_pData->m_nAllocLength); |
116 m_pData->m_nDataLength = nNewLength; | 116 m_pData->m_nDataLength = nNewLength; |
117 m_pData->m_String[nNewLength] = 0; | 117 m_pData->m_String[nNewLength] = 0; |
118 } | 118 } |
119 const CFX_WideString& CFX_WideString::operator=(const FX_WCHAR* lpsz) { | 119 const CFX_WideString& CFX_WideString::operator=(const FX_WCHAR* lpsz) { |
120 if (lpsz == NULL || lpsz[0] == 0) { | 120 if (!lpsz || lpsz[0] == 0) { |
121 Empty(); | 121 Empty(); |
122 } else { | 122 } else { |
123 AssignCopy(FXSYS_wcslen(lpsz), lpsz); | 123 AssignCopy(FXSYS_wcslen(lpsz), lpsz); |
124 } | 124 } |
125 return *this; | 125 return *this; |
126 } | 126 } |
127 const CFX_WideString& CFX_WideString::operator=( | 127 const CFX_WideString& CFX_WideString::operator=( |
128 const CFX_WideStringC& stringSrc) { | 128 const CFX_WideStringC& stringSrc) { |
129 if (stringSrc.IsEmpty()) { | 129 if (stringSrc.IsEmpty()) { |
130 Empty(); | 130 Empty(); |
(...skipping 25 matching lines...) Expand all Loading... | |
156 ConcatInPlace(1, &ch); | 156 ConcatInPlace(1, &ch); |
157 return *this; | 157 return *this; |
158 } | 158 } |
159 const CFX_WideString& CFX_WideString::operator+=(const FX_WCHAR* lpsz) { | 159 const CFX_WideString& CFX_WideString::operator+=(const FX_WCHAR* lpsz) { |
160 if (lpsz) { | 160 if (lpsz) { |
161 ConcatInPlace(FXSYS_wcslen(lpsz), lpsz); | 161 ConcatInPlace(FXSYS_wcslen(lpsz), lpsz); |
162 } | 162 } |
163 return *this; | 163 return *this; |
164 } | 164 } |
165 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideString& string) { | 165 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideString& string) { |
166 if (string.m_pData == NULL) { | 166 if (!string.m_pData) { |
167 return *this; | 167 return *this; |
168 } | 168 } |
169 ConcatInPlace(string.m_pData->m_nDataLength, string.m_pData->m_String); | 169 ConcatInPlace(string.m_pData->m_nDataLength, string.m_pData->m_String); |
170 return *this; | 170 return *this; |
171 } | 171 } |
172 const CFX_WideString& CFX_WideString::operator+=( | 172 const CFX_WideString& CFX_WideString::operator+=( |
173 const CFX_WideStringC& string) { | 173 const CFX_WideStringC& string) { |
174 if (string.IsEmpty()) { | 174 if (string.IsEmpty()) { |
175 return *this; | 175 return *this; |
176 } | 176 } |
177 ConcatInPlace(string.GetLength(), string.GetPtr()); | 177 ConcatInPlace(string.GetLength(), string.GetPtr()); |
178 return *this; | 178 return *this; |
179 } | 179 } |
180 bool CFX_WideString::Equal(const wchar_t* ptr) const { | 180 bool CFX_WideString::Equal(const wchar_t* ptr) const { |
181 if (!m_pData) { | 181 if (!m_pData) { |
182 return !ptr || ptr[0] == L'\0'; | 182 return !ptr || ptr[0] == L'\0'; |
183 } | 183 } |
184 if (!ptr) { | 184 if (!ptr) { |
185 return m_pData->m_nDataLength == 0; | 185 return m_pData->m_nDataLength == 0; |
186 } | 186 } |
187 return wcslen(ptr) == m_pData->m_nDataLength && | 187 return wcslen(ptr) == m_pData->m_nDataLength && |
188 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; | 188 wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0; |
189 } | 189 } |
190 bool CFX_WideString::Equal(const CFX_WideStringC& str) const { | 190 bool CFX_WideString::Equal(const CFX_WideStringC& str) const { |
191 if (m_pData == NULL) { | 191 if (!m_pData) { |
192 return str.IsEmpty(); | 192 return str.IsEmpty(); |
193 } | 193 } |
194 return str.GetLength() == m_pData->m_nDataLength && | 194 return str.GetLength() == m_pData->m_nDataLength && |
195 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; | 195 wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0; |
196 } | 196 } |
197 bool CFX_WideString::Equal(const CFX_WideString& other) const { | 197 bool CFX_WideString::Equal(const CFX_WideString& other) const { |
198 if (IsEmpty()) { | 198 if (IsEmpty()) { |
199 return other.IsEmpty(); | 199 return other.IsEmpty(); |
200 } | 200 } |
201 if (other.IsEmpty()) { | 201 if (other.IsEmpty()) { |
202 return false; | 202 return false; |
203 } | 203 } |
204 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && | 204 return other.m_pData->m_nDataLength == m_pData->m_nDataLength && |
205 wmemcmp(other.m_pData->m_String, m_pData->m_String, | 205 wmemcmp(other.m_pData->m_String, m_pData->m_String, |
206 m_pData->m_nDataLength) == 0; | 206 m_pData->m_nDataLength) == 0; |
207 } | 207 } |
208 void CFX_WideString::Empty() { | 208 void CFX_WideString::Empty() { |
209 if (m_pData) { | 209 if (m_pData) { |
210 m_pData->Release(); | 210 m_pData->Release(); |
211 m_pData = NULL; | 211 m_pData = NULL; |
212 } | 212 } |
213 } | 213 } |
214 void CFX_WideString::ConcatInPlace(FX_STRSIZE nSrcLen, | 214 void CFX_WideString::ConcatInPlace(FX_STRSIZE nSrcLen, |
215 const FX_WCHAR* lpszSrcData) { | 215 const FX_WCHAR* lpszSrcData) { |
216 if (nSrcLen == 0 || lpszSrcData == NULL) { | 216 if (nSrcLen == 0 || !lpszSrcData) { |
217 return; | 217 return; |
218 } | 218 } |
219 if (m_pData == NULL) { | 219 if (!m_pData) { |
220 m_pData = StringData::Create(nSrcLen); | 220 m_pData = StringData::Create(nSrcLen); |
221 if (m_pData) { | 221 if (m_pData) { |
222 FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR)); | 222 FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR)); |
223 } | 223 } |
224 return; | 224 return; |
225 } | 225 } |
226 if (m_pData->m_nRefs > 1 || | 226 if (m_pData->m_nRefs > 1 || |
227 m_pData->m_nDataLength + nSrcLen > m_pData->m_nAllocLength) { | 227 m_pData->m_nDataLength + nSrcLen > m_pData->m_nAllocLength) { |
228 ConcatCopy(m_pData->m_nDataLength, m_pData->m_String, nSrcLen, lpszSrcData); | 228 ConcatCopy(m_pData->m_nDataLength, m_pData->m_String, nSrcLen, lpszSrcData); |
229 } else { | 229 } else { |
(...skipping 14 matching lines...) Expand all Loading... | |
244 // Don't release until done copying, might be one of the arguments. | 244 // Don't release until done copying, might be one of the arguments. |
245 StringData* pOldData = m_pData; | 245 StringData* pOldData = m_pData; |
246 m_pData = StringData::Create(nNewLen); | 246 m_pData = StringData::Create(nNewLen); |
247 if (m_pData) { | 247 if (m_pData) { |
248 wmemcpy(m_pData->m_String, lpszSrc1Data, nSrc1Len); | 248 wmemcpy(m_pData->m_String, lpszSrc1Data, nSrc1Len); |
249 wmemcpy(m_pData->m_String + nSrc1Len, lpszSrc2Data, nSrc2Len); | 249 wmemcpy(m_pData->m_String + nSrc1Len, lpszSrc2Data, nSrc2Len); |
250 } | 250 } |
251 pOldData->Release(); | 251 pOldData->Release(); |
252 } | 252 } |
253 void CFX_WideString::CopyBeforeWrite() { | 253 void CFX_WideString::CopyBeforeWrite() { |
254 if (m_pData == NULL || m_pData->m_nRefs <= 1) { | 254 if (!m_pData || m_pData->m_nRefs <= 1) { |
255 return; | 255 return; |
256 } | 256 } |
257 StringData* pData = m_pData; | 257 StringData* pData = m_pData; |
258 m_pData->Release(); | 258 m_pData->Release(); |
259 FX_STRSIZE nDataLength = pData->m_nDataLength; | 259 FX_STRSIZE nDataLength = pData->m_nDataLength; |
260 m_pData = StringData::Create(nDataLength); | 260 m_pData = StringData::Create(nDataLength); |
261 if (m_pData) { | 261 if (m_pData) { |
262 FXSYS_memcpy(m_pData->m_String, pData->m_String, | 262 FXSYS_memcpy(m_pData->m_String, pData->m_String, |
263 (nDataLength + 1) * sizeof(FX_WCHAR)); | 263 (nDataLength + 1) * sizeof(FX_WCHAR)); |
264 } | 264 } |
265 } | 265 } |
266 void CFX_WideString::AllocBeforeWrite(FX_STRSIZE nLen) { | 266 void CFX_WideString::AllocBeforeWrite(FX_STRSIZE nLen) { |
267 if (m_pData && m_pData->m_nRefs <= 1 && m_pData->m_nAllocLength >= nLen) { | 267 if (m_pData && m_pData->m_nRefs <= 1 && m_pData->m_nAllocLength >= nLen) { |
268 return; | 268 return; |
269 } | 269 } |
270 Empty(); | 270 Empty(); |
271 m_pData = StringData::Create(nLen); | 271 m_pData = StringData::Create(nLen); |
272 } | 272 } |
273 void CFX_WideString::AssignCopy(FX_STRSIZE nSrcLen, | 273 void CFX_WideString::AssignCopy(FX_STRSIZE nSrcLen, |
274 const FX_WCHAR* lpszSrcData) { | 274 const FX_WCHAR* lpszSrcData) { |
275 AllocBeforeWrite(nSrcLen); | 275 AllocBeforeWrite(nSrcLen); |
276 FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR)); | 276 FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR)); |
277 m_pData->m_nDataLength = nSrcLen; | 277 m_pData->m_nDataLength = nSrcLen; |
278 m_pData->m_String[nSrcLen] = 0; | 278 m_pData->m_String[nSrcLen] = 0; |
279 } | 279 } |
280 int CFX_WideString::Compare(const FX_WCHAR* lpsz) const { | 280 int CFX_WideString::Compare(const FX_WCHAR* lpsz) const { |
281 if (m_pData == NULL) { | 281 if (!m_pData) { |
Tom Sepez
2015/12/14 18:27:00
nit: maybe flip around to avoid !
Lei Zhang
2015/12/15 01:58:36
Done.
| |
282 return (lpsz == NULL || lpsz[0] == 0) ? 0 : -1; | 282 return (!lpsz || lpsz[0] == 0) ? 0 : -1; |
283 } | 283 } |
284 return FXSYS_wcscmp(m_pData->m_String, lpsz); | 284 return FXSYS_wcscmp(m_pData->m_String, lpsz); |
285 } | 285 } |
286 CFX_ByteString CFX_WideString::UTF8Encode() const { | 286 CFX_ByteString CFX_WideString::UTF8Encode() const { |
287 return FX_UTF8Encode(*this); | 287 return FX_UTF8Encode(*this); |
288 } | 288 } |
289 CFX_ByteString CFX_WideString::UTF16LE_Encode() const { | 289 CFX_ByteString CFX_WideString::UTF16LE_Encode() const { |
290 if (m_pData == NULL) { | 290 if (!m_pData) { |
291 return CFX_ByteString("\0\0"); | 291 return CFX_ByteString("\0\0"); |
292 } | 292 } |
293 int len = m_pData->m_nDataLength; | 293 int len = m_pData->m_nDataLength; |
294 CFX_ByteString result; | 294 CFX_ByteString result; |
295 FX_CHAR* buffer = result.GetBuffer(len * 2 + 2); | 295 FX_CHAR* buffer = result.GetBuffer(len * 2 + 2); |
296 for (int i = 0; i < len; i++) { | 296 for (int i = 0; i < len; i++) { |
297 buffer[i * 2] = m_pData->m_String[i] & 0xff; | 297 buffer[i * 2] = m_pData->m_String[i] & 0xff; |
298 buffer[i * 2 + 1] = m_pData->m_String[i] >> 8; | 298 buffer[i * 2 + 1] = m_pData->m_String[i] >> 8; |
299 } | 299 } |
300 buffer[len * 2] = 0; | 300 buffer[len * 2] = 0; |
301 buffer[len * 2 + 1] = 0; | 301 buffer[len * 2 + 1] = 0; |
302 result.ReleaseBuffer(len * 2 + 2); | 302 result.ReleaseBuffer(len * 2 + 2); |
303 return result; | 303 return result; |
304 } | 304 } |
305 void CFX_WideString::ConvertFrom(const CFX_ByteString& str, | 305 void CFX_WideString::ConvertFrom(const CFX_ByteString& str, |
306 CFX_CharMap* pCharMap) { | 306 CFX_CharMap* pCharMap) { |
307 if (pCharMap == NULL) { | 307 if (!pCharMap) { |
308 pCharMap = CFX_CharMap::GetDefaultMapper(); | 308 pCharMap = CFX_CharMap::GetDefaultMapper(); |
309 } | 309 } |
310 *this = pCharMap->m_GetWideString(pCharMap, str); | 310 *this = pCharMap->m_GetWideString(pCharMap, str); |
311 } | 311 } |
312 void CFX_WideString::Reserve(FX_STRSIZE len) { | 312 void CFX_WideString::Reserve(FX_STRSIZE len) { |
313 GetBuffer(len); | 313 GetBuffer(len); |
314 ReleaseBuffer(GetLength()); | 314 ReleaseBuffer(GetLength()); |
315 } | 315 } |
316 FX_WCHAR* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) { | 316 FX_WCHAR* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) { |
317 if (m_pData == NULL && nMinBufLength == 0) { | 317 if (!m_pData && nMinBufLength == 0) { |
318 return NULL; | 318 return NULL; |
319 } | 319 } |
320 if (m_pData && m_pData->m_nRefs <= 1 && | 320 if (m_pData && m_pData->m_nRefs <= 1 && |
321 m_pData->m_nAllocLength >= nMinBufLength) { | 321 m_pData->m_nAllocLength >= nMinBufLength) { |
322 return m_pData->m_String; | 322 return m_pData->m_String; |
323 } | 323 } |
324 if (m_pData == NULL) { | 324 if (!m_pData) { |
325 m_pData = StringData::Create(nMinBufLength); | 325 m_pData = StringData::Create(nMinBufLength); |
326 if (!m_pData) { | 326 if (!m_pData) { |
327 return NULL; | 327 return NULL; |
328 } | 328 } |
329 m_pData->m_nDataLength = 0; | 329 m_pData->m_nDataLength = 0; |
330 m_pData->m_String[0] = 0; | 330 m_pData->m_String[0] = 0; |
331 return m_pData->m_String; | 331 return m_pData->m_String; |
332 } | 332 } |
333 StringData* pOldData = m_pData; | 333 StringData* pOldData = m_pData; |
334 FX_STRSIZE nOldLen = pOldData->m_nDataLength; | 334 FX_STRSIZE nOldLen = pOldData->m_nDataLength; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 FX_STRSIZE nCopyLen, | 387 FX_STRSIZE nCopyLen, |
388 FX_STRSIZE nCopyIndex) const { | 388 FX_STRSIZE nCopyIndex) const { |
389 // |FX_STRSIZE| is currently typedef'd as in |int|. TODO(palmer): It | 389 // |FX_STRSIZE| is currently typedef'd as in |int|. TODO(palmer): It |
390 // should be a |size_t|, or at least unsigned. | 390 // should be a |size_t|, or at least unsigned. |
391 if (nCopyLen == 0 || nCopyLen < 0) { | 391 if (nCopyLen == 0 || nCopyLen < 0) { |
392 return; | 392 return; |
393 } | 393 } |
394 pdfium::base::CheckedNumeric<FX_STRSIZE> iSize = | 394 pdfium::base::CheckedNumeric<FX_STRSIZE> iSize = |
395 static_cast<FX_STRSIZE>(sizeof(FX_WCHAR)); | 395 static_cast<FX_STRSIZE>(sizeof(FX_WCHAR)); |
396 iSize *= nCopyLen; | 396 iSize *= nCopyLen; |
397 ASSERT(dest.m_pData == NULL); | 397 ASSERT(!dest.m_pData); |
398 dest.m_pData = StringData::Create(nCopyLen); | 398 dest.m_pData = StringData::Create(nCopyLen); |
399 if (dest.m_pData) { | 399 if (dest.m_pData) { |
400 FXSYS_memcpy(dest.m_pData->m_String, m_pData->m_String + nCopyIndex, | 400 FXSYS_memcpy(dest.m_pData->m_String, m_pData->m_String + nCopyIndex, |
401 iSize.ValueOrDie()); | 401 iSize.ValueOrDie()); |
402 } | 402 } |
403 } | 403 } |
404 CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const { | 404 CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const { |
405 if (m_pData == NULL) { | 405 if (!m_pData) { |
406 return CFX_WideString(); | 406 return CFX_WideString(); |
407 } | 407 } |
408 if (nCount < 0) { | 408 if (nCount < 0) { |
409 nCount = 0; | 409 nCount = 0; |
410 } | 410 } |
411 if (nCount >= m_pData->m_nDataLength) { | 411 if (nCount >= m_pData->m_nDataLength) { |
412 return *this; | 412 return *this; |
413 } | 413 } |
414 CFX_WideString dest; | 414 CFX_WideString dest; |
415 AllocCopy(dest, nCount, 0); | 415 AllocCopy(dest, nCount, 0); |
416 return dest; | 416 return dest; |
417 } | 417 } |
418 CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst) const { | 418 CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst) const { |
419 return Mid(nFirst, m_pData->m_nDataLength - nFirst); | 419 return Mid(nFirst, m_pData->m_nDataLength - nFirst); |
420 } | 420 } |
421 CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const { | 421 CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const { |
422 if (m_pData == NULL) { | 422 if (!m_pData) { |
423 return CFX_WideString(); | 423 return CFX_WideString(); |
424 } | 424 } |
425 if (nFirst < 0) { | 425 if (nFirst < 0) { |
426 nFirst = 0; | 426 nFirst = 0; |
427 } | 427 } |
428 if (nCount < 0) { | 428 if (nCount < 0) { |
429 nCount = 0; | 429 nCount = 0; |
430 } | 430 } |
431 if (nFirst + nCount > m_pData->m_nDataLength) { | 431 if (nFirst + nCount > m_pData->m_nDataLength) { |
432 nCount = m_pData->m_nDataLength - nFirst; | 432 nCount = m_pData->m_nDataLength - nFirst; |
433 } | 433 } |
434 if (nFirst > m_pData->m_nDataLength) { | 434 if (nFirst > m_pData->m_nDataLength) { |
435 nCount = 0; | 435 nCount = 0; |
436 } | 436 } |
437 if (nFirst == 0 && nFirst + nCount == m_pData->m_nDataLength) { | 437 if (nFirst == 0 && nFirst + nCount == m_pData->m_nDataLength) { |
438 return *this; | 438 return *this; |
439 } | 439 } |
440 CFX_WideString dest; | 440 CFX_WideString dest; |
441 AllocCopy(dest, nCount, nFirst); | 441 AllocCopy(dest, nCount, nFirst); |
442 return dest; | 442 return dest; |
443 } | 443 } |
444 CFX_WideString CFX_WideString::Right(FX_STRSIZE nCount) const { | 444 CFX_WideString CFX_WideString::Right(FX_STRSIZE nCount) const { |
445 if (m_pData == NULL) { | 445 if (!m_pData) { |
446 return CFX_WideString(); | 446 return CFX_WideString(); |
447 } | 447 } |
448 if (nCount < 0) { | 448 if (nCount < 0) { |
449 nCount = 0; | 449 nCount = 0; |
450 } | 450 } |
451 if (nCount >= m_pData->m_nDataLength) { | 451 if (nCount >= m_pData->m_nDataLength) { |
452 return *this; | 452 return *this; |
453 } | 453 } |
454 CFX_WideString dest; | 454 CFX_WideString dest; |
455 AllocCopy(dest, nCount, m_pData->m_nDataLength - nCount); | 455 AllocCopy(dest, nCount, m_pData->m_nDataLength - nCount); |
456 return dest; | 456 return dest; |
457 } | 457 } |
458 int CFX_WideString::CompareNoCase(const FX_WCHAR* lpsz) const { | 458 int CFX_WideString::CompareNoCase(const FX_WCHAR* lpsz) const { |
459 if (m_pData == NULL) { | 459 if (!m_pData) { |
460 return (lpsz == NULL || lpsz[0] == 0) ? 0 : -1; | 460 return (!lpsz || lpsz[0] == 0) ? 0 : -1; |
461 } | 461 } |
462 return FXSYS_wcsicmp(m_pData->m_String, lpsz); | 462 return FXSYS_wcsicmp(m_pData->m_String, lpsz); |
463 } | 463 } |
464 int CFX_WideString::Compare(const CFX_WideString& str) const { | 464 int CFX_WideString::Compare(const CFX_WideString& str) const { |
465 if (m_pData == NULL) { | 465 if (!m_pData) { |
466 if (str.m_pData == NULL) { | 466 if (!str.m_pData) { |
467 return 0; | 467 return 0; |
468 } | 468 } |
469 return -1; | 469 return -1; |
470 } | 470 } |
471 if (str.m_pData == NULL) { | 471 if (!str.m_pData) { |
472 return 1; | 472 return 1; |
473 } | 473 } |
474 int this_len = m_pData->m_nDataLength; | 474 int this_len = m_pData->m_nDataLength; |
475 int that_len = str.m_pData->m_nDataLength; | 475 int that_len = str.m_pData->m_nDataLength; |
476 int min_len = this_len < that_len ? this_len : that_len; | 476 int min_len = this_len < that_len ? this_len : that_len; |
477 for (int i = 0; i < min_len; i++) { | 477 for (int i = 0; i < min_len; i++) { |
478 if (m_pData->m_String[i] < str.m_pData->m_String[i]) { | 478 if (m_pData->m_String[i] < str.m_pData->m_String[i]) { |
479 return -1; | 479 return -1; |
480 } | 480 } |
481 if (m_pData->m_String[i] > str.m_pData->m_String[i]) { | 481 if (m_pData->m_String[i] > str.m_pData->m_String[i]) { |
482 return 1; | 482 return 1; |
483 } | 483 } |
484 } | 484 } |
485 if (this_len < that_len) { | 485 if (this_len < that_len) { |
486 return -1; | 486 return -1; |
487 } | 487 } |
488 if (this_len > that_len) { | 488 if (this_len > that_len) { |
489 return 1; | 489 return 1; |
490 } | 490 } |
491 return 0; | 491 return 0; |
492 } | 492 } |
493 void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) { | 493 void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) { |
494 if (m_pData == NULL) { | 494 if (!m_pData) { |
495 return; | 495 return; |
496 } | 496 } |
497 ASSERT(nIndex >= 0); | 497 ASSERT(nIndex >= 0); |
498 ASSERT(nIndex < m_pData->m_nDataLength); | 498 ASSERT(nIndex < m_pData->m_nDataLength); |
499 CopyBeforeWrite(); | 499 CopyBeforeWrite(); |
500 m_pData->m_String[nIndex] = ch; | 500 m_pData->m_String[nIndex] = ch; |
501 } | 501 } |
502 void CFX_WideString::MakeLower() { | 502 void CFX_WideString::MakeLower() { |
503 if (m_pData == NULL) { | 503 if (!m_pData) { |
504 return; | 504 return; |
505 } | 505 } |
506 CopyBeforeWrite(); | 506 CopyBeforeWrite(); |
507 if (GetLength() < 1) { | 507 if (GetLength() < 1) { |
508 return; | 508 return; |
509 } | 509 } |
510 FXSYS_wcslwr(m_pData->m_String); | 510 FXSYS_wcslwr(m_pData->m_String); |
511 } | 511 } |
512 void CFX_WideString::MakeUpper() { | 512 void CFX_WideString::MakeUpper() { |
513 if (m_pData == NULL) { | 513 if (!m_pData) { |
514 return; | 514 return; |
515 } | 515 } |
516 CopyBeforeWrite(); | 516 CopyBeforeWrite(); |
517 if (GetLength() < 1) { | 517 if (GetLength() < 1) { |
518 return; | 518 return; |
519 } | 519 } |
520 FXSYS_wcsupr(m_pData->m_String); | 520 FXSYS_wcsupr(m_pData->m_String); |
521 } | 521 } |
522 FX_STRSIZE CFX_WideString::Find(const FX_WCHAR* lpszSub, | 522 FX_STRSIZE CFX_WideString::Find(const FX_WCHAR* lpszSub, |
523 FX_STRSIZE nStart) const { | 523 FX_STRSIZE nStart) const { |
524 FX_STRSIZE nLength = GetLength(); | 524 FX_STRSIZE nLength = GetLength(); |
525 if (nLength < 1 || nStart > nLength) { | 525 if (nLength < 1 || nStart > nLength) { |
526 return -1; | 526 return -1; |
527 } | 527 } |
528 const FX_WCHAR* lpsz = FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub); | 528 const FX_WCHAR* lpsz = FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub); |
529 return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String); | 529 return lpsz ? (int)(lpsz - m_pData->m_String) : -1; |
530 } | 530 } |
531 FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const { | 531 FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const { |
532 if (m_pData == NULL) { | 532 if (!m_pData) { |
533 return -1; | 533 return -1; |
534 } | 534 } |
535 FX_STRSIZE nLength = m_pData->m_nDataLength; | 535 FX_STRSIZE nLength = m_pData->m_nDataLength; |
536 if (nStart >= nLength) { | 536 if (nStart >= nLength) { |
537 return -1; | 537 return -1; |
538 } | 538 } |
539 const FX_WCHAR* lpsz = FXSYS_wcschr(m_pData->m_String + nStart, ch); | 539 const FX_WCHAR* lpsz = FXSYS_wcschr(m_pData->m_String + nStart, ch); |
540 return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String); | 540 return (lpsz) ? (int)(lpsz - m_pData->m_String) : -1; |
541 } | 541 } |
542 void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) { | 542 void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) { |
543 FXSYS_assert(lpszTargetList); | 543 FXSYS_assert(lpszTargetList); |
544 if (m_pData == NULL || *lpszTargetList == 0) { | 544 if (!m_pData || *lpszTargetList == 0) { |
545 return; | 545 return; |
546 } | 546 } |
547 CopyBeforeWrite(); | 547 CopyBeforeWrite(); |
548 FX_STRSIZE len = GetLength(); | 548 FX_STRSIZE len = GetLength(); |
549 if (len < 1) { | 549 if (len < 1) { |
550 return; | 550 return; |
551 } | 551 } |
552 FX_STRSIZE pos = len; | 552 FX_STRSIZE pos = len; |
553 while (pos) { | 553 while (pos) { |
554 if (FXSYS_wcschr(lpszTargetList, m_pData->m_String[pos - 1]) == NULL) { | 554 if (!FXSYS_wcschr(lpszTargetList, m_pData->m_String[pos - 1])) { |
555 break; | 555 break; |
556 } | 556 } |
557 pos--; | 557 pos--; |
558 } | 558 } |
559 if (pos < len) { | 559 if (pos < len) { |
560 m_pData->m_String[pos] = 0; | 560 m_pData->m_String[pos] = 0; |
561 m_pData->m_nDataLength = pos; | 561 m_pData->m_nDataLength = pos; |
562 } | 562 } |
563 } | 563 } |
564 void CFX_WideString::TrimRight(FX_WCHAR chTarget) { | 564 void CFX_WideString::TrimRight(FX_WCHAR chTarget) { |
565 FX_WCHAR str[2] = {chTarget, 0}; | 565 FX_WCHAR str[2] = {chTarget, 0}; |
566 TrimRight(str); | 566 TrimRight(str); |
567 } | 567 } |
568 void CFX_WideString::TrimRight() { | 568 void CFX_WideString::TrimRight() { |
569 TrimRight(L"\x09\x0a\x0b\x0c\x0d\x20"); | 569 TrimRight(L"\x09\x0a\x0b\x0c\x0d\x20"); |
570 } | 570 } |
571 void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) { | 571 void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) { |
572 FXSYS_assert(lpszTargets); | 572 FXSYS_assert(lpszTargets); |
573 if (m_pData == NULL || *lpszTargets == 0) { | 573 if (!m_pData || *lpszTargets == 0) { |
574 return; | 574 return; |
575 } | 575 } |
576 CopyBeforeWrite(); | 576 CopyBeforeWrite(); |
577 if (GetLength() < 1) { | 577 if (GetLength() < 1) { |
578 return; | 578 return; |
579 } | 579 } |
580 const FX_WCHAR* lpsz = m_pData->m_String; | 580 const FX_WCHAR* lpsz = m_pData->m_String; |
581 while (*lpsz != 0) { | 581 while (*lpsz != 0) { |
582 if (FXSYS_wcschr(lpszTargets, *lpsz) == NULL) { | 582 if (!FXSYS_wcschr(lpszTargets, *lpsz)) { |
583 break; | 583 break; |
584 } | 584 } |
585 lpsz++; | 585 lpsz++; |
586 } | 586 } |
587 if (lpsz != m_pData->m_String) { | 587 if (lpsz != m_pData->m_String) { |
588 int nDataLength = | 588 int nDataLength = |
589 m_pData->m_nDataLength - (FX_STRSIZE)(lpsz - m_pData->m_String); | 589 m_pData->m_nDataLength - (FX_STRSIZE)(lpsz - m_pData->m_String); |
590 FXSYS_memmove(m_pData->m_String, lpsz, | 590 FXSYS_memmove(m_pData->m_String, lpsz, |
591 (nDataLength + 1) * sizeof(FX_WCHAR)); | 591 (nDataLength + 1) * sizeof(FX_WCHAR)); |
592 m_pData->m_nDataLength = nDataLength; | 592 m_pData->m_nDataLength = nDataLength; |
593 } | 593 } |
594 } | 594 } |
595 void CFX_WideString::TrimLeft(FX_WCHAR chTarget) { | 595 void CFX_WideString::TrimLeft(FX_WCHAR chTarget) { |
596 FX_WCHAR str[2] = {chTarget, 0}; | 596 FX_WCHAR str[2] = {chTarget, 0}; |
597 TrimLeft(str); | 597 TrimLeft(str); |
598 } | 598 } |
599 void CFX_WideString::TrimLeft() { | 599 void CFX_WideString::TrimLeft() { |
600 TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20"); | 600 TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20"); |
601 } | 601 } |
602 FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, | 602 FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, |
603 const FX_WCHAR* lpszNew) { | 603 const FX_WCHAR* lpszNew) { |
604 if (GetLength() < 1) { | 604 if (GetLength() < 1) { |
605 return 0; | 605 return 0; |
606 } | 606 } |
607 if (lpszOld == NULL) { | 607 if (!lpszOld) { |
608 return 0; | 608 return 0; |
609 } | 609 } |
610 FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld); | 610 FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld); |
611 if (nSourceLen == 0) { | 611 if (nSourceLen == 0) { |
612 return 0; | 612 return 0; |
613 } | 613 } |
614 FX_STRSIZE nReplacementLen = lpszNew ? FXSYS_wcslen(lpszNew) : 0; | 614 FX_STRSIZE nReplacementLen = lpszNew ? FXSYS_wcslen(lpszNew) : 0; |
615 FX_STRSIZE nCount = 0; | 615 FX_STRSIZE nCount = 0; |
616 FX_WCHAR* lpszStart = m_pData->m_String; | 616 FX_WCHAR* lpszStart = m_pData->m_String; |
617 FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength; | 617 FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) { | 664 FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) { |
665 CopyBeforeWrite(); | 665 CopyBeforeWrite(); |
666 if (nIndex < 0) { | 666 if (nIndex < 0) { |
667 nIndex = 0; | 667 nIndex = 0; |
668 } | 668 } |
669 FX_STRSIZE nNewLength = GetLength(); | 669 FX_STRSIZE nNewLength = GetLength(); |
670 if (nIndex > nNewLength) { | 670 if (nIndex > nNewLength) { |
671 nIndex = nNewLength; | 671 nIndex = nNewLength; |
672 } | 672 } |
673 nNewLength++; | 673 nNewLength++; |
674 if (m_pData == NULL || m_pData->m_nAllocLength < nNewLength) { | 674 if (!m_pData || m_pData->m_nAllocLength < nNewLength) { |
675 StringData* pOldData = m_pData; | 675 StringData* pOldData = m_pData; |
676 const FX_WCHAR* pstr = m_pData->m_String; | 676 const FX_WCHAR* pstr = m_pData->m_String; |
677 m_pData = StringData::Create(nNewLength); | 677 m_pData = StringData::Create(nNewLength); |
678 if (!m_pData) { | 678 if (!m_pData) { |
679 return 0; | 679 return 0; |
680 } | 680 } |
681 if (pOldData) { | 681 if (pOldData) { |
682 FXSYS_memmove(m_pData->m_String, pstr, | 682 FXSYS_memmove(m_pData->m_String, pstr, |
683 (pOldData->m_nDataLength + 1) * sizeof(FX_WCHAR)); | 683 (pOldData->m_nDataLength + 1) * sizeof(FX_WCHAR)); |
684 pOldData->Release(); | 684 pOldData->Release(); |
(...skipping 19 matching lines...) Expand all Loading... | |
704 CopyBeforeWrite(); | 704 CopyBeforeWrite(); |
705 int nBytesToCopy = nOldLength - (nIndex + nCount) + 1; | 705 int nBytesToCopy = nOldLength - (nIndex + nCount) + 1; |
706 FXSYS_memmove(m_pData->m_String + nIndex, | 706 FXSYS_memmove(m_pData->m_String + nIndex, |
707 m_pData->m_String + nIndex + nCount, | 707 m_pData->m_String + nIndex + nCount, |
708 nBytesToCopy * sizeof(FX_WCHAR)); | 708 nBytesToCopy * sizeof(FX_WCHAR)); |
709 m_pData->m_nDataLength = nOldLength - nCount; | 709 m_pData->m_nDataLength = nOldLength - nCount; |
710 } | 710 } |
711 return m_pData->m_nDataLength; | 711 return m_pData->m_nDataLength; |
712 } | 712 } |
713 FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) { | 713 FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) { |
714 if (m_pData == NULL) { | 714 if (!m_pData) { |
715 return 0; | 715 return 0; |
716 } | 716 } |
717 CopyBeforeWrite(); | 717 CopyBeforeWrite(); |
718 if (GetLength() < 1) { | 718 if (GetLength() < 1) { |
719 return 0; | 719 return 0; |
720 } | 720 } |
721 FX_WCHAR* pstrSource = m_pData->m_String; | 721 FX_WCHAR* pstrSource = m_pData->m_String; |
722 FX_WCHAR* pstrDest = m_pData->m_String; | 722 FX_WCHAR* pstrDest = m_pData->m_String; |
723 FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; | 723 FX_WCHAR* pstrEnd = m_pData->m_String + m_pData->m_nDataLength; |
724 while (pstrSource < pstrEnd) { | 724 while (pstrSource < pstrEnd) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 nItemLen = 2; | 824 nItemLen = 2; |
825 va_arg(argList, int); | 825 va_arg(argList, int); |
826 break; | 826 break; |
827 case 'c' | FORCE_UNICODE: | 827 case 'c' | FORCE_UNICODE: |
828 case 'C' | FORCE_UNICODE: | 828 case 'C' | FORCE_UNICODE: |
829 nItemLen = 2; | 829 nItemLen = 2; |
830 va_arg(argList, int); | 830 va_arg(argList, int); |
831 break; | 831 break; |
832 case 's': { | 832 case 's': { |
833 const FX_WCHAR* pstrNextArg = va_arg(argList, const FX_WCHAR*); | 833 const FX_WCHAR* pstrNextArg = va_arg(argList, const FX_WCHAR*); |
834 if (pstrNextArg == NULL) { | 834 if (pstrNextArg) { |
835 nItemLen = 6; | |
836 } else { | |
837 nItemLen = FXSYS_wcslen(pstrNextArg); | 835 nItemLen = FXSYS_wcslen(pstrNextArg); |
838 if (nItemLen < 1) { | 836 if (nItemLen < 1) { |
839 nItemLen = 1; | 837 nItemLen = 1; |
840 } | 838 } |
839 } else { | |
840 nItemLen = 6; | |
841 } | 841 } |
842 } break; | 842 } break; |
843 case 'S': { | 843 case 'S': { |
844 const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); | 844 const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); |
845 if (pstrNextArg == NULL) { | 845 if (pstrNextArg) { |
846 nItemLen = 6; | |
847 } else { | |
848 nItemLen = FXSYS_strlen(pstrNextArg); | 846 nItemLen = FXSYS_strlen(pstrNextArg); |
849 if (nItemLen < 1) { | 847 if (nItemLen < 1) { |
850 nItemLen = 1; | 848 nItemLen = 1; |
851 } | 849 } |
850 } else { | |
851 nItemLen = 6; | |
852 } | 852 } |
853 } break; | 853 } break; |
854 case 's' | FORCE_ANSI: | 854 case 's' | FORCE_ANSI: |
855 case 'S' | FORCE_ANSI: { | 855 case 'S' | FORCE_ANSI: { |
856 const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); | 856 const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*); |
857 if (pstrNextArg == NULL) { | 857 if (pstrNextArg) { |
858 nItemLen = 6; | |
859 } else { | |
860 nItemLen = FXSYS_strlen(pstrNextArg); | 858 nItemLen = FXSYS_strlen(pstrNextArg); |
861 if (nItemLen < 1) { | 859 if (nItemLen < 1) { |
862 nItemLen = 1; | 860 nItemLen = 1; |
863 } | 861 } |
862 } else { | |
863 nItemLen = 6; | |
864 } | 864 } |
865 } break; | 865 } break; |
866 case 's' | FORCE_UNICODE: | 866 case 's' | FORCE_UNICODE: |
867 case 'S' | FORCE_UNICODE: { | 867 case 'S' | FORCE_UNICODE: { |
868 FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*); | 868 FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*); |
869 if (pstrNextArg == NULL) { | 869 if (pstrNextArg) { |
870 nItemLen = 6; | |
871 } else { | |
872 nItemLen = FXSYS_wcslen(pstrNextArg); | 870 nItemLen = FXSYS_wcslen(pstrNextArg); |
873 if (nItemLen < 1) { | 871 if (nItemLen < 1) { |
874 nItemLen = 1; | 872 nItemLen = 1; |
875 } | 873 } |
874 } else { | |
875 nItemLen = 6; | |
876 } | 876 } |
877 } break; | 877 } break; |
878 } | 878 } |
879 if (nItemLen != 0) { | 879 if (nItemLen != 0) { |
880 if (nPrecision != 0 && nItemLen > nPrecision) { | 880 if (nPrecision != 0 && nItemLen > nPrecision) { |
881 nItemLen = nPrecision; | 881 nItemLen = nPrecision; |
882 } | 882 } |
883 if (nItemLen < nWidth) { | 883 if (nItemLen < nWidth) { |
884 nItemLen = nWidth; | 884 nItemLen = nWidth; |
885 } | 885 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
980 while (cc < len) { | 980 while (cc < len) { |
981 fraction += scale * FXSYS_toDecimalDigitWide(str[cc]); | 981 fraction += scale * FXSYS_toDecimalDigitWide(str[cc]); |
982 scale *= 0.1f; | 982 scale *= 0.1f; |
983 cc++; | 983 cc++; |
984 } | 984 } |
985 } | 985 } |
986 fraction += (FX_FLOAT)integer; | 986 fraction += (FX_FLOAT)integer; |
987 return bNegative ? -fraction : fraction; | 987 return bNegative ? -fraction : fraction; |
988 } | 988 } |
989 int CFX_WideString::GetInteger() const { | 989 int CFX_WideString::GetInteger() const { |
990 if (m_pData == NULL) { | 990 return m_pData ? FXSYS_wtoi(m_pData->m_String) : 0; |
991 return 0; | |
992 } | |
993 return FXSYS_wtoi(m_pData->m_String); | |
994 } | 991 } |
995 FX_FLOAT CFX_WideString::GetFloat() const { | 992 FX_FLOAT CFX_WideString::GetFloat() const { |
996 if (m_pData == NULL) { | 993 return m_pData ? FX_wtof(m_pData->m_String, m_pData->m_nDataLength) : 0.0; |
997 return 0.0; | |
998 } | |
999 return FX_wtof(m_pData->m_String, m_pData->m_nDataLength); | |
1000 } | 994 } |
1001 static CFX_ByteString _DefMap_GetByteString(CFX_CharMap* pCharMap, | 995 static CFX_ByteString _DefMap_GetByteString(CFX_CharMap* pCharMap, |
1002 const CFX_WideString& widestr) { | 996 const CFX_WideString& widestr) { |
1003 int src_len = widestr.GetLength(); | 997 int src_len = widestr.GetLength(); |
1004 int codepage = pCharMap->m_GetCodePage ? pCharMap->m_GetCodePage() : 0; | 998 int codepage = pCharMap->m_GetCodePage ? pCharMap->m_GetCodePage() : 0; |
1005 int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, widestr.c_str(), | 999 int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, widestr.c_str(), |
1006 src_len, NULL, 0, NULL, NULL); | 1000 src_len, NULL, 0, NULL, NULL); |
1007 if (dest_len == 0) { | 1001 if (dest_len == 0) { |
1008 return CFX_ByteString(); | 1002 return CFX_ByteString(); |
1009 } | 1003 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 return (CFX_CharMap*)&g_DefaultJISMapper; | 1053 return (CFX_CharMap*)&g_DefaultJISMapper; |
1060 case 936: | 1054 case 936: |
1061 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1055 return (CFX_CharMap*)&g_DefaultGBKMapper; |
1062 case 949: | 1056 case 949: |
1063 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1057 return (CFX_CharMap*)&g_DefaultUHCMapper; |
1064 case 950: | 1058 case 950: |
1065 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1059 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
1066 } | 1060 } |
1067 return NULL; | 1061 return NULL; |
1068 } | 1062 } |
OLD | NEW |