summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_basic_bstring.cpp2
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp5
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp6
-rw-r--r--core/fxcrt/fx_xml_parser.cpp6
-rw-r--r--core/fxcrt/include/fx_basic.h10
-rw-r--r--core/fxcrt/include/fx_string.h3
6 files changed, 17 insertions, 15 deletions
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp
index 3a81e41920..c774e80cb7 100644
--- a/core/fxcrt/fx_basic_bstring.cpp
+++ b/core/fxcrt/fx_basic_bstring.cpp
@@ -820,7 +820,7 @@ CFX_WideString CFX_ByteString::UTF8Decode() const {
for (FX_STRSIZE i = 0; i < GetLength(); i++) {
decoder.Input((uint8_t)m_pData->m_String[i]);
}
- return decoder.GetResult();
+ return CFX_WideString(decoder.GetResult());
}
// static
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index 5a75f8b487..6008a00b40 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -186,11 +186,6 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideTextBuf& buf) {
return *this;
}
-CFX_WideStringC CFX_WideTextBuf::AsStringC() const {
- return CFX_WideStringC(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
- m_DataSize / sizeof(FX_WCHAR));
-}
-
#ifdef PDF_ENABLE_XFA
CFX_ArchiveSaver& CFX_ArchiveSaver::operator<<(uint8_t i) {
if (m_pStream) {
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index 8c1d494e7a..241c3a6985 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -786,10 +786,10 @@ CFX_WideString CFX_WideString::FromUTF8(const CFX_ByteStringC& str) {
return CFX_WideString();
CFX_UTF8Decoder decoder;
- for (FX_STRSIZE i = 0; i < str.GetLength(); i++) {
+ for (FX_STRSIZE i = 0; i < str.GetLength(); i++)
decoder.Input(str[i]);
- }
- return decoder.GetResult();
+
+ return CFX_WideString(decoder.GetResult());
}
// static
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index 4b52189142..a5e351fe56 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -457,7 +457,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
iState = 10;
} else {
content << decoder.GetResult();
- CFX_WideString dataStr = content.AsStringC();
+ CFX_WideString dataStr = content.MakeString();
if (!bCDATA && !m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
@@ -501,7 +501,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent,
}
} while (ReadNextBlock());
content << decoder.GetResult();
- CFX_WideString dataStr = content.AsStringC();
+ CFX_WideString dataStr = content.MakeString();
if (!m_bSaveSpaceChars) {
dataStr.TrimRight(L" \t\r\n");
}
@@ -784,7 +784,7 @@ void CXML_AttrMap::SetAt(const CFX_ByteStringC& space,
}
}
- m_pMap->push_back({space, name, value});
+ m_pMap->push_back({space, name, CFX_WideString(value)});
}
int CXML_AttrMap::GetSize() const {
diff --git a/core/fxcrt/include/fx_basic.h b/core/fxcrt/include/fx_basic.h
index 7437d9567c..48999c4f19 100644
--- a/core/fxcrt/include/fx_basic.h
+++ b/core/fxcrt/include/fx_basic.h
@@ -80,7 +80,15 @@ class CFX_WideTextBuf : public CFX_BinaryBuf {
FX_WCHAR* GetBuffer() const {
return reinterpret_cast<FX_WCHAR*>(m_pBuffer.get());
}
- CFX_WideStringC AsStringC() const;
+
+ CFX_WideStringC AsStringC() const {
+ return CFX_WideStringC(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
+ m_DataSize / sizeof(FX_WCHAR));
+ }
+ CFX_WideString MakeString() const {
+ return CFX_WideString(reinterpret_cast<const FX_WCHAR*>(m_pBuffer.get()),
+ m_DataSize / sizeof(FX_WCHAR));
+ }
void Delete(int start_index, int count) {
CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR),
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index 9019522eca..df8afb386f 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -250,8 +250,7 @@ class CFX_WideString {
CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
- // TODO(tsepez): mark constructor as explicit.
- CFX_WideString(const CFX_WideStringC& str);
+ explicit CFX_WideString(const CFX_WideStringC& str);
CFX_WideString(const CFX_WideStringC& str1, const CFX_WideStringC& str2);
~CFX_WideString();