Contents Up Previous Next

String functions

::copystring
::wxStringMatch
::wxStringEq
::IsEmpty
::Stricmp
::Strlen
::wxGetTranslation
::wxSnprintf
::wxVsnprintf


::copystring

char* copystring(const char* s)

Makes a copy of the string s using the C++ new operator, so it can be deleted with the delete operator.


::wxStringMatch

bool wxStringMatch(const wxString& s1, const wxString& s2,
bool subString = TRUE, bool exact = FALSE)

Returns TRUE if the substring s1 is found within s2, ignoring case if exact is FALSE. If subString is FALSE, no substring matching is done.


::wxStringEq

bool wxStringEq(const wxString& s1, const wxString& s2)

A macro defined as:

#define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0))

::IsEmpty

bool IsEmpty(const char * p)

Returns TRUE if the string is empty, FALSE otherwise. It is safe to pass NULL pointer to this function and it will return TRUE for it.


::Stricmp

int Stricmp(const char *p1, const char *p2)

Returns a negative value, 0, or positive value if p1 is less than, equal to or greater than p2. The comparison is case-insensitive.

This function complements the standard C function strcmp() which performs case-sensitive comparison.


::Strlen

size_t Strlen(const char * p)

This is a safe version of standard function strlen(): it does exactly the same thing (i.e. returns the length of the string) except that it returns 0 if p is the NULL pointer.


::wxGetTranslation

const char * wxGetTranslation(const char * str)

This function returns the translation of string str in the current locale. If the string is not found in any of the loaded message catalogs (see internationalization overview), the original string is returned. In debug build, an error message is logged - this should help to find the strings which were not yet translated. As this function is used very often, an alternative syntax is provided: the _() macro is defined as wxGetTranslation().


::wxSnprintf

int wxSnprintf(wxChar *buf, size_t len, const wxChar *format, ...)

This function replaces the dangerous standard function sprintf() and is like snprintf() available on some platforms. The only difference with sprintf() is that an additional argument - buffer size - is taken and the buffer is never overflowed.

Returns the number of characters copied to the buffer or -1 if there is not enough space.

See also

wxVsnprintf, wxString::Printf


::wxVsnprintf

int wxVsnprintf(wxChar *buf, size_t len, const wxChar *format, va_list argptr)

The same as wxSnprintf but takes a va_list argument instead of arbitrary number of parameters.

See also

wxSnprintf, wxString::PrintfV