check that string passed to FromUTF8() is valid even in release build, this is safer; add a separate FromUTF8Unchecked() which can be used for maximal efficiency

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54721 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-07-19 19:59:59 +00:00
parent 9f10e7c758
commit cc209a518f
5 changed files with 61 additions and 12 deletions

View File

@@ -623,14 +623,39 @@ public:
//@{
/**
Converts C string encoded in UTF-8 to wxString.
Note that this method assumes that @a s is a valid UTF-8 sequence and
doesn't do any validation in release builds, it's validity is only checked in
debug builds.
If @a s is not a valid UTF-8 string, an empty string is returned.
Notice that when using UTF-8 wxWidgets build there is a more efficient
alternative to this function called FromUTF8Unchecked() which, unlike
this one, doesn't check that the input string is valid.
@since 2.8.4
*/
static wxString FromUTF8(const char* s);
static wxString FromUTF8(const char* s, size_t len);
//@}
//@{
/**
Converts C string encoded in UTF-8 to wxString without checking its
validity.
This method assumes that @a s is a valid UTF-8 sequence and doesn't do
any validation (although an assert failure is triggered in debug builds
if the string is invalid). Only use it if you are absolutely sure that
@a s is a correct UTF-8 string (e.g. because it comes from another
library using UTF-8) and if the performance matters, otherwise use
slower (in UTF-8 build) but safer FromUTF8(). Passing a bad UTF-8
string to this function will result in creating a corrupted wxString
and all the subsequent operations on it will be undefined.
@since 2.8.9
*/
static wxString FromUTF8Unchecked(const char* s);
static wxString FromUTF8Unchecked(const char* s, size_t len);
//@}
/**
Returns the character at position @a n (read-only).
*/