diff options
author | Lei Zhang <thestig@chromium.org> | 2016-02-19 10:53:24 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2016-02-19 10:53:24 -0800 |
commit | 31c7b73b71bd7352f96a82716b5e81d7fa24f37f (patch) | |
tree | 292a068fb657e97cd0d11dc78a7528915f8a78e0 /core/src/fxcrt | |
parent | 490543247e07ce1c92f609bcc2fa484652a86e1f (diff) | |
download | pdfium-31c7b73b71bd7352f96a82716b5e81d7fa24f37f.tar.xz |
Remove CFX_{Byte,Wide}String::ConvertFrom().
Use/add CFX_{Byte,Wide}String::FromFoo() instead.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1711893003 .
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r-- | core/src/fxcrt/fx_basic_bstring.cpp | 23 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_wstring.cpp | 28 | ||||
-rw-r--r-- | core/src/fxcrt/fx_extension.cpp | 3 |
3 files changed, 28 insertions, 26 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp index e0d1146068..85e5041095 100644 --- a/core/src/fxcrt/fx_basic_bstring.cpp +++ b/core/src/fxcrt/fx_basic_bstring.cpp @@ -910,25 +910,20 @@ CFX_WideString CFX_ByteString::UTF8Decode() const { } return decoder.GetResult(); } + +// static CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str, FX_STRSIZE len) { - if (len < 0) { - len = FXSYS_wcslen(str); - } - CFX_ByteString bstr; - bstr.ConvertFrom(CFX_WideString(str, len)); - return bstr; + FX_STRSIZE str_len = len >= 0 ? len : FXSYS_wcslen(str); + return FromUnicode(CFX_WideString(str, str_len)); } + +// static CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) { - return FromUnicode(str.c_str(), str.GetLength()); -} -void CFX_ByteString::ConvertFrom(const CFX_WideString& str, - CFX_CharMap* pCharMap) { - if (!pCharMap) { - pCharMap = CFX_CharMap::GetDefaultMapper(); - } - *this = (*pCharMap->m_GetByteString)(pCharMap, str); + CFX_CharMap* pCharMap = CFX_CharMap::GetDefaultMapper(); + return (*pCharMap->m_GetByteString)(pCharMap, str); } + int CFX_ByteString::Compare(const CFX_ByteStringC& str) const { if (!m_pData) { return str.IsEmpty() ? 0 : -1; diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index 2370c87cf1..d83aa85213 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -303,13 +303,7 @@ CFX_ByteString CFX_WideString::UTF16LE_Encode() const { result.ReleaseBuffer(len * 2 + 2); return result; } -void CFX_WideString::ConvertFrom(const CFX_ByteString& str, - CFX_CharMap* pCharMap) { - if (!pCharMap) { - pCharMap = CFX_CharMap::GetDefaultMapper(); - } - *this = pCharMap->m_GetWideString(pCharMap, str); -} + void CFX_WideString::Reserve(FX_STRSIZE len) { GetBuffer(len); ReleaseBuffer(GetLength()); @@ -346,11 +340,20 @@ FX_WCHAR* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) { pOldData->Release(); return m_pData->m_String; } -CFX_WideString CFX_WideString::FromLocal(const char* str, FX_STRSIZE len) { - CFX_WideString result; - result.ConvertFrom(CFX_ByteString(str, len)); - return result; + +// static +CFX_WideString CFX_WideString::FromLocal(const CFX_ByteString& str) { + return FromCodePage(str, 0); } + +// static +CFX_WideString CFX_WideString::FromCodePage(const CFX_ByteString& str, + FX_WORD codepage) { + CFX_CharMap* pCharMap = CFX_CharMap::GetDefaultMapper(codepage); + return pCharMap->m_GetWideString(pCharMap, str); +} + +// static CFX_WideString CFX_WideString::FromUTF8(const char* str, FX_STRSIZE len) { if (!str || 0 == len) { return CFX_WideString(); @@ -362,6 +365,8 @@ CFX_WideString CFX_WideString::FromUTF8(const char* str, FX_STRSIZE len) { } return decoder.GetResult(); } + +// static CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, FX_STRSIZE wlen) { if (!wstr || 0 == wlen) { @@ -376,6 +381,7 @@ CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, result.ReleaseBuffer(wlen); return result; } + FX_STRSIZE CFX_WideString::WStringLength(const unsigned short* str) { FX_STRSIZE len = 0; if (str) diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp index fa6245c9d3..cae1763c7e 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -133,7 +133,8 @@ FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, if (iLength < 0) { iLength = (int32_t)FXSYS_strlen(pcsStr); } - CFX_WideString ws = CFX_WideString::FromLocal(pcsStr, iLength); + CFX_WideString ws = + CFX_WideString::FromLocal(CFX_ByteString(pcsStr, iLength)); return FXSYS_wcstof(ws.c_str(), iLength, pUsedLen); } FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, |