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 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 uint16_t codepage) { | 779 uint16_t codepage) { |
780 return CFX_CharMap::GetWideString(codepage, str); | 780 return CFX_CharMap::GetWideString(codepage, str); |
781 } | 781 } |
782 | 782 |
783 // static | 783 // static |
784 CFX_WideString CFX_WideString::FromUTF8(const CFX_ByteStringC& str) { | 784 CFX_WideString CFX_WideString::FromUTF8(const CFX_ByteStringC& str) { |
785 if (str.IsEmpty()) | 785 if (str.IsEmpty()) |
786 return CFX_WideString(); | 786 return CFX_WideString(); |
787 | 787 |
788 CFX_UTF8Decoder decoder; | 788 CFX_UTF8Decoder decoder; |
789 for (FX_STRSIZE i = 0; i < str.GetLength(); i++) { | 789 for (FX_STRSIZE i = 0; i < str.GetLength(); i++) |
790 decoder.Input(str[i]); | 790 decoder.Input(str[i]); |
791 } | 791 |
792 return decoder.GetResult(); | 792 return CFX_WideString(decoder.GetResult()); |
793 } | 793 } |
794 | 794 |
795 // static | 795 // static |
796 CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, | 796 CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, |
797 FX_STRSIZE wlen) { | 797 FX_STRSIZE wlen) { |
798 if (!wstr || 0 == wlen) { | 798 if (!wstr || 0 == wlen) { |
799 return CFX_WideString(); | 799 return CFX_WideString(); |
800 } | 800 } |
801 | 801 |
802 CFX_WideString result; | 802 CFX_WideString result; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); | 987 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, nullptr, 0); |
988 CFX_WideString wstr; | 988 CFX_WideString wstr; |
989 if (dest_len) { | 989 if (dest_len) { |
990 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); | 990 FX_WCHAR* dest_buf = wstr.GetBuffer(dest_len); |
991 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, | 991 FXSYS_MultiByteToWideChar(codepage, 0, bstr.c_str(), src_len, dest_buf, |
992 dest_len); | 992 dest_len); |
993 wstr.ReleaseBuffer(dest_len); | 993 wstr.ReleaseBuffer(dest_len); |
994 } | 994 } |
995 return wstr; | 995 return wstr; |
996 } | 996 } |
OLD | NEW |