summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fxcrt/fx_basic_utf.cpp8
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp4
-rw-r--r--core/fxcrt/fx_string.h11
-rw-r--r--core/fxcrt/fx_xml_parser.cpp2
4 files changed, 8 insertions, 17 deletions
diff --git a/core/fxcrt/fx_basic_utf.cpp b/core/fxcrt/fx_basic_utf.cpp
index 8dbbb28877..c0f14c8178 100644
--- a/core/fxcrt/fx_basic_utf.cpp
+++ b/core/fxcrt/fx_basic_utf.cpp
@@ -73,13 +73,13 @@ void CFX_UTF8Encoder::Input(FX_WCHAR unicode) {
}
}
}
-CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len) {
- if (len < 0)
- len = FXSYS_wcslen(pwsStr);
+CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) {
+ FX_STRSIZE len = wsStr.GetLength();
+ const FX_WCHAR* pStr = wsStr.c_str();
CFX_UTF8Encoder encoder;
while (len-- > 0)
- encoder.Input(*pwsStr++);
+ encoder.Input(*pStr++);
return CFX_ByteString(encoder.GetResult());
}
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index e779621e60..93b9ba7c25 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -343,12 +343,10 @@ void CFX_WideString::Concat(const FX_WCHAR* pSrcData, FX_STRSIZE nSrcLen) {
m_pData.Swap(pNewData);
}
-// static
CFX_ByteString CFX_WideString::UTF8Encode() const {
- return FX_UTF8Encode(*this);
+ return FX_UTF8Encode(AsStringC());
}
-// static
CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
if (!m_pData) {
return CFX_ByteString("\0\0", 2);
diff --git a/core/fxcrt/fx_string.h b/core/fxcrt/fx_string.h
index 750216fd3e..cd93f27275 100644
--- a/core/fxcrt/fx_string.h
+++ b/core/fxcrt/fx_string.h
@@ -424,17 +424,10 @@ inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) {
return rhs != lhs;
}
-CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len);
-inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) {
- return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
-}
-inline CFX_ByteString FX_UTF8Encode(const CFX_WideString& wsStr) {
- return FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength());
-}
-
+CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr);
FX_FLOAT FX_atof(const CFX_ByteStringC& str);
inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) {
- return FX_atof(FX_UTF8Encode(wsStr.c_str(), wsStr.GetLength()).c_str());
+ return FX_atof(FX_UTF8Encode(wsStr).c_str());
}
bool FX_atonum(const CFX_ByteStringC& str, void* pData);
FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index 1b562c2083..7658620424 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -773,7 +773,7 @@ CFX_ByteString CXML_Element::GetNamespaceURI(
}
pElement = pElement->GetParent();
} while (pElement);
- return pwsSpace ? FX_UTF8Encode(*pwsSpace) : CFX_ByteString();
+ return pwsSpace ? pwsSpace->UTF8Encode() : CFX_ByteString();
}
void CXML_Element::GetAttrByIndex(int index,
CFX_ByteString& space,