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

Unified Diff: core/src/fxcrt/fx_basic_wstring.cpp

Issue 1711893003: Remove CFX_{Byte,Wide}String::ConvertFrom(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: address comments Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_extension.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_wstring.cpp
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 2370c87cf18a450d419df7be4ce148bb964d1205..d83aa852136c4fea093348b2318e4d4d0c10d99d 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)
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_extension.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698