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 "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
8 #include "../../../third_party/numerics/safe_math.h" | 8 #include "../../../third_party/numerics/safe_math.h" |
9 | 9 |
10 static CFX_StringDataW* FX_AllocStringW(int nLen) | 10 static CFX_StringDataW* FX_AllocStringW(int nLen) |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 return m_pData->m_String; | 391 return m_pData->m_String; |
392 } | 392 } |
393 CFX_WideString CFX_WideString::FromLocal(const char* str, FX_STRSIZE len) | 393 CFX_WideString CFX_WideString::FromLocal(const char* str, FX_STRSIZE len) |
394 { | 394 { |
395 CFX_WideString result; | 395 CFX_WideString result; |
396 result.ConvertFrom(CFX_ByteString(str, len)); | 396 result.ConvertFrom(CFX_ByteString(str, len)); |
397 return result; | 397 return result; |
398 } | 398 } |
399 CFX_WideString CFX_WideString::FromUTF8(const char* str, FX_STRSIZE len) | 399 CFX_WideString CFX_WideString::FromUTF8(const char* str, FX_STRSIZE len) |
400 { | 400 { |
401 if (!str) { | 401 if (!str) { |
palmer
2014/07/12 00:54:39
You could say:
if (!str || 0 == len)
to avoi
Bo Xu
2014/07/12 05:18:04
Done.
| |
402 return CFX_WideString(); | 402 return CFX_WideString(); |
403 } | 403 } |
404 if (len < 0) { | 404 |
405 len = 0; | |
406 while (str[len]) { | |
407 len ++; | |
408 } | |
409 } | |
410 CFX_UTF8Decoder decoder; | 405 CFX_UTF8Decoder decoder; |
411 for (FX_STRSIZE i = 0; i < len; i ++) { | 406 for (FX_STRSIZE i = 0; i < len; i ++) { |
412 decoder.Input(str[i]); | 407 decoder.Input(str[i]); |
413 } | 408 } |
414 return decoder.GetResult(); | 409 return decoder.GetResult(); |
415 } | 410 } |
416 CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, FX_STRSIZ E wlen) | 411 CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, FX_STRSIZ E wlen) |
417 { | 412 { |
418 if (!wstr || !wlen) { | 413 if (!wstr || !wlen) { |
419 return CFX_WideString(); | 414 return CFX_WideString(); |
420 } | 415 } |
421 if (wlen < 0) { | 416 |
422 wlen = 0; | |
423 while (wstr[wlen]) { | |
424 wlen ++; | |
425 } | |
426 } | |
427 CFX_WideString result; | 417 CFX_WideString result; |
428 FX_WCHAR* buf = result.GetBuffer(wlen); | 418 FX_WCHAR* buf = result.GetBuffer(wlen); |
429 for (int i = 0; i < wlen; i ++) { | 419 for (int i = 0; i < wlen; i ++) { |
430 buf[i] = wstr[i]; | 420 buf[i] = wstr[i]; |
431 } | 421 } |
432 result.ReleaseBuffer(wlen); | 422 result.ReleaseBuffer(wlen); |
433 return result; | 423 return result; |
434 } | 424 } |
435 void CFX_WideString::AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STR SIZE nCopyIndex) const | 425 void CFX_WideString::AllocCopy(CFX_WideString& dest, FX_STRSIZE nCopyLen, FX_STR SIZE nCopyIndex) const |
436 { | 426 { |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1120 return (CFX_CharMap*)&g_DefaultJISMapper; | 1110 return (CFX_CharMap*)&g_DefaultJISMapper; |
1121 case 936: | 1111 case 936: |
1122 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1112 return (CFX_CharMap*)&g_DefaultGBKMapper; |
1123 case 949: | 1113 case 949: |
1124 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1114 return (CFX_CharMap*)&g_DefaultUHCMapper; |
1125 case 950: | 1115 case 950: |
1126 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1116 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
1127 } | 1117 } |
1128 return NULL; | 1118 return NULL; |
1129 } | 1119 } |
OLD | NEW |