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> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 return FromCodePage(str, 0); | 365 return FromCodePage(str, 0); |
366 } | 366 } |
367 | 367 |
368 // static | 368 // static |
369 CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteString& str, | 369 CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteString& str, |
370 uint16_t codepage) { | 370 uint16_t codepage) { |
371 return CFX_CharMap::GetWideString(codepage, str); | 371 return CFX_CharMap::GetWideString(codepage, str); |
372 } | 372 } |
373 | 373 |
374 // static | 374 // static |
375 CFX_WideString CFX_WideString::FromUTF8(const char* str, FX_STRSIZE len) { | 375 CFX_WideString CFX_WideString::FromUTF8(const CFX_ByteStringC& str) { |
376 if (!str || 0 == len) { | 376 if (str.IsEmpty()) |
377 return CFX_WideString(); | 377 return CFX_WideString(); |
378 } | |
379 | 378 |
380 CFX_UTF8Decoder decoder; | 379 CFX_UTF8Decoder decoder; |
381 for (FX_STRSIZE i = 0; i < len; i++) { | 380 for (FX_STRSIZE i = 0; i < str.GetLength(); i++) { |
382 decoder.Input(str[i]); | 381 decoder.Input(str[i]); |
383 } | 382 } |
384 return decoder.GetResult(); | 383 return decoder.GetResult(); |
385 } | 384 } |
386 | 385 |
387 // static | 386 // static |
388 CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, | 387 CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, |
389 FX_STRSIZE wlen) { | 388 FX_STRSIZE wlen) { |
390 if (!wstr || 0 == wlen) { | 389 if (!wstr || 0 == wlen) { |
391 return CFX_WideString(); | 390 return CFX_WideString(); |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 int dest_len = | 1033 int dest_len = |
1035 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0); | 1034 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, nullptr, 0); |
1036 CFX_WideString wstr; | 1035 CFX_WideString wstr; |
1037 if (dest_len) { | 1036 if (dest_len) { |
1038 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); | 1037 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); |
1039 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len); | 1038 FXSYS_MultiByteToWideChar(codepage, 0, bstr, src_len, dest_buf, dest_len); |
1040 wstr.ReleaseBuffer(dest_len); | 1039 wstr.ReleaseBuffer(dest_len); |
1041 } | 1040 } |
1042 return wstr; | 1041 return wstr; |
1043 } | 1042 } |
OLD | NEW |