Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Side by Side Diff: core/src/fxcrt/fx_basic_wstring.cpp

Issue 1511773002: Revert "Merge to master: Take Jun's UTF16LE patches." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 == NULL) {
282 return (lpsz == NULL || lpsz[0] == 0) ? 0 : -1; 282 return (lpsz == NULL || 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 CFX_ByteString result; 290 if (m_pData == NULL) {
291 if (!m_pData) { 291 return CFX_ByteString(FX_BSTRC("\0\0"));
292 return result;
293 } 292 }
294 int len = m_pData->m_nDataLength; 293 int len = m_pData->m_nDataLength;
295 FX_CHAR* buffer = result.GetBuffer(len * 2); 294 CFX_ByteString result;
296 for (int i = 0; i < len; ++i) { 295 FX_CHAR* buffer = result.GetBuffer(len * 2 + 2);
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 result.ReleaseBuffer(len * 2); 300 buffer[len * 2] = 0;
301 buffer[len * 2 + 1] = 0;
302 result.ReleaseBuffer(len * 2 + 2);
301 return result; 303 return result;
302 } 304 }
303 void CFX_WideString::ConvertFrom(const CFX_ByteString& str, 305 void CFX_WideString::ConvertFrom(const CFX_ByteString& str,
304 CFX_CharMap* pCharMap) { 306 CFX_CharMap* pCharMap) {
305 if (pCharMap == NULL) { 307 if (pCharMap == NULL) {
306 pCharMap = CFX_CharMap::GetDefaultMapper(); 308 pCharMap = CFX_CharMap::GetDefaultMapper();
307 } 309 }
308 *this = pCharMap->m_GetWideString(pCharMap, str); 310 *this = pCharMap->m_GetWideString(pCharMap, str);
309 } 311 }
310 void CFX_WideString::Reserve(FX_STRSIZE len) { 312 void CFX_WideString::Reserve(FX_STRSIZE len) {
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 return (CFX_CharMap*)&g_DefaultJISMapper; 1059 return (CFX_CharMap*)&g_DefaultJISMapper;
1058 case 936: 1060 case 936:
1059 return (CFX_CharMap*)&g_DefaultGBKMapper; 1061 return (CFX_CharMap*)&g_DefaultGBKMapper;
1060 case 949: 1062 case 949:
1061 return (CFX_CharMap*)&g_DefaultUHCMapper; 1063 return (CFX_CharMap*)&g_DefaultUHCMapper;
1062 case 950: 1064 case 950:
1063 return (CFX_CharMap*)&g_DefaultBig5Mapper; 1065 return (CFX_CharMap*)&g_DefaultBig5Mapper;
1064 } 1066 }
1065 return NULL; 1067 return NULL;
1066 } 1068 }
OLDNEW
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698