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/base/numerics/safe_math.h" | 8 #include "../../../third_party/base/numerics/safe_math.h" |
9 | 9 |
10 static CFX_StringDataW* FX_AllocStringW(int nLen) | 10 static CFX_StringDataW* FX_AllocStringW(int nLen) |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 { | 1055 { |
1056 if (m_pData == NULL) { | 1056 if (m_pData == NULL) { |
1057 return 0.0; | 1057 return 0.0; |
1058 } | 1058 } |
1059 return FX_wtof(m_pData->m_String, m_pData->m_nDataLength); | 1059 return FX_wtof(m_pData->m_String, m_pData->m_nDataLength); |
1060 } | 1060 } |
1061 static CFX_ByteString _DefMap_GetByteString(CFX_CharMap* pCharMap, const CFX_Wid
eString& widestr) | 1061 static CFX_ByteString _DefMap_GetByteString(CFX_CharMap* pCharMap, const CFX_Wid
eString& widestr) |
1062 { | 1062 { |
1063 int src_len = widestr.GetLength(); | 1063 int src_len = widestr.GetLength(); |
1064 int codepage = pCharMap->m_GetCodePage ? pCharMap->m_GetCodePage() : 0; | 1064 int codepage = pCharMap->m_GetCodePage ? pCharMap->m_GetCodePage() : 0; |
1065 int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, widestr, src_len, NULL
, 0, NULL, NULL); | 1065 int dest_len = FXSYS_WideCharToMultiByte(codepage, 0, widestr.c_str(), src_l
en, NULL, 0, NULL, NULL); |
1066 if (dest_len == 0) { | 1066 if (dest_len == 0) { |
1067 return CFX_ByteString(); | 1067 return CFX_ByteString(); |
1068 } | 1068 } |
1069 CFX_ByteString bytestr; | 1069 CFX_ByteString bytestr; |
1070 FX_LPSTR dest_buf = bytestr.GetBuffer(dest_len); | 1070 FX_LPSTR dest_buf = bytestr.GetBuffer(dest_len); |
1071 FXSYS_WideCharToMultiByte(codepage, 0, widestr, src_len, dest_buf, dest_len,
NULL, NULL); | 1071 FXSYS_WideCharToMultiByte(codepage, 0, widestr.c_str(), src_len, dest_buf, d
est_len, NULL, NULL); |
1072 bytestr.ReleaseBuffer(dest_len); | 1072 bytestr.ReleaseBuffer(dest_len); |
1073 return bytestr; | 1073 return bytestr; |
1074 } | 1074 } |
1075 static CFX_WideString _DefMap_GetWideString(CFX_CharMap* pCharMap, const CFX_Byt
eString& bytestr) | 1075 static CFX_WideString _DefMap_GetWideString(CFX_CharMap* pCharMap, const CFX_Byt
eString& bytestr) |
1076 { | 1076 { |
1077 int src_len = bytestr.GetLength(); | 1077 int src_len = bytestr.GetLength(); |
1078 int codepage = pCharMap->m_GetCodePage ? pCharMap->m_GetCodePage() : 0; | 1078 int codepage = pCharMap->m_GetCodePage ? pCharMap->m_GetCodePage() : 0; |
1079 int dest_len = FXSYS_MultiByteToWideChar(codepage, 0, bytestr, src_len, NULL
, 0); | 1079 int dest_len = FXSYS_MultiByteToWideChar(codepage, 0, bytestr, src_len, NULL
, 0); |
1080 if (dest_len == 0) { | 1080 if (dest_len == 0) { |
1081 return CFX_WideString(); | 1081 return CFX_WideString(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 return (CFX_CharMap*)&g_DefaultJISMapper; | 1116 return (CFX_CharMap*)&g_DefaultJISMapper; |
1117 case 936: | 1117 case 936: |
1118 return (CFX_CharMap*)&g_DefaultGBKMapper; | 1118 return (CFX_CharMap*)&g_DefaultGBKMapper; |
1119 case 949: | 1119 case 949: |
1120 return (CFX_CharMap*)&g_DefaultUHCMapper; | 1120 return (CFX_CharMap*)&g_DefaultUHCMapper; |
1121 case 950: | 1121 case 950: |
1122 return (CFX_CharMap*)&g_DefaultBig5Mapper; | 1122 return (CFX_CharMap*)&g_DefaultBig5Mapper; |
1123 } | 1123 } |
1124 return NULL; | 1124 return NULL; |
1125 } | 1125 } |
OLD | NEW |