[Libreoffice-commits] core.git: include/rtl
Miklos Vajna
vmiklos at collabora.co.uk
Wed Nov 5 08:45:09 PST 2014
include/rtl/ustring.hxx | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
New commits:
commit 3943daaa353ca3cd4ae1873249c94ed2856dd99a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Nov 5 15:25:18 2014 +0100
rtl::OUString::fromUtf8(): use rtl_convertStringToUString()
So that we can assert if the input wasn't valid UTF-8.
Change-Id: I626a5874b37553b2fe76acfea2ce7d9d9fd38725
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 4550869..9ffe5a1 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -2078,20 +2078,21 @@ public:
* Convert an OString to an OUString, assuming that the OString is
* UTF-8-encoded.
*
- * @param rStr
+ * @param rSource
* an OString to convert
*
- * @param convertFlags
- * flags which control the conversion.
- *
- * @see rtl::OStringToOUString for more info on convertFlags.
- *
* @since LibreOffice 4.4
*/
- static inline OUString fromUtf8(const OString& rStr,
- sal_uInt32 convertFlags = OSTRING_TO_OUSTRING_CVTFLAGS)
- {
- return OUString(rStr.getStr(), rStr.getLength(), RTL_TEXTENCODING_UTF8, convertFlags);
+ static inline OUString fromUtf8(const OString& rSource)
+ {
+ OUString aTarget;
+ bool bSuccess = rtl_convertStringToUString(&aTarget.pData,
+ rSource.getStr(),
+ rSource.getLength(),
+ RTL_TEXTENCODING_UTF8,
+ RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR|RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR|RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR);
+ assert(bSuccess);
+ return aTarget;
}
/**
More information about the Libreoffice-commits
mailing list