Allow calling wxStrchr() with a narrow string and wide character.

Calls to wxStrchr(char-string, wide-char) would previously fail if wide
character couldn't be converted to a single character in the current locale
encoding. Change it to simply return NULL in this case as it's a safe and
useful generalization: a narrow string will never contain a wide character not
representable in the current locale.

Add wxUniChar::GetAsChar() to help with implementing this.

Closes #11487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-11-28 14:37:03 +00:00
parent 85b1997c09
commit 874dbd3a4a
5 changed files with 105 additions and 39 deletions

View File

@@ -58,6 +58,30 @@ public:
*/
bool IsAscii() const;
/**
Returns true if the character is representable as a single byte in the
current locale encoding.
This function only returns true if the character can be converted in
exactly one byte, e.g. it only returns true for 7 bit ASCII characters
when the encoding used is UTF-8.
It is mostly useful to test if the character can be passed to functions
taking a char and is used by wxWidgets itself for this purpose.
@param c
An output pointer to the value of this Unicode character as a @c
char. Must be non-@NULL.
@return
@true if the object is an 8 bit char and @a c was filled with its
value as char or @false otherwise (@a c won't be modified then).
@see IsAscii()
@since 2.9.1
*/
bool GetAsChar(char *c) const;
//@{
/**
Conversions to char and wchar_t types: all of those are needed to be