::copystring
::wxGetTranslation
::wxIsEmpty
::wxStrcmp
::wxStricmp
::wxStringMatch
::wxStringEq
::wxStrlen
::wxSnprintf
wxT
wxTRANSLATE
::wxVsnprintf
_
_T
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.
This function is deprecated, use wxString class instead.
const char * wxGetTranslation(const char * str)
const char * wxGetTranslation(const char * str, const char * strPlural, size_t n)
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 (and also common in Unix world) syntax is provided: the _() macro is defined to do the same thing as wxGetTranslation.
The second form is used when retrieving translation of string that has different singular and plural form in English or different plural forms in some other language. It takes two extra arguments: str parameter must contain the singular form of the string to be converted. It is also used as the key for the search in the catalog. The strPlural parameter is the plural form (in English). The parameter n is used to determine the plural form. If no message catalog is found str is returned if 'n == 1', otherwise strPlural. See GNU gettext manual for additional information on plural forms handling.
Both versions call wxLocale::GetString.
bool wxIsEmpty(const char * p)
Returns true if the pointer is either NULL or points to an empty string, false otherwise.
int wxStrcmp(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-sensitive.
This function complements the standard C function stricmp() which performs case-insensitive comparison.
int wxStricmp(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.
bool wxStringMatch(const wxString& s1, const wxString& s2,
bool subString = true, bool exact = false)
NB: This function is obsolete, use wxString::Find instead.
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.
bool wxStringEq(const wxString& s1, const wxString& s2)
NB: This function is obsolete, use wxString instead.
A macro defined as:
#define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0))
size_t wxStrlen(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.
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
wxChar wxT(char ch)
const wxChar * wxT(const char *s)
wxT() is a macro which can be used with character and string literals (in other words, 'x' or "foo") to automatically convert them to Unicode in Unicode build configuration. Please see the Unicode overview for more information.
This macro is simply returns the value passed to it without changes in ASCII build. In fact, its definition is:
#ifdef UNICODE #define wxT(x) L ## x #else // !Unicode #define wxT(x) x #endif
const wxChar * wxTRANSLATE(const char *s)
This macro doesn't do anything in the program code -- it simply expands to the value of its argument (except in Unicode build where it is equivalent to wxT which makes it unnecessary to use both wxTRANSLATE and wxT with the same string which would be really unreadable).
However it does have a purpose and it is to mark the literal strings for the extraction into the message catalog created by xgettext program. Usually this is achieved using _() but that macro not only marks the string for extraction but also expands into a wxGetTranslation function call which means that it cannot be used in some situations, notably for static array initialization.
Here is an example which should make it more clear: suppose that you have a static array of strings containing the weekday names and which have to be translated (note that it is a bad example, really, as wxDateTime already can be used to get the localized week day names already). If you write
static const wxChar * const weekdays[] = { _("Mon"), ..., _("Sun") }; ... // use weekdays[n] as usualthe code wouldn't compile because the function calls are forbidden in the array initializer. So instead you should do
static const wxChar * const weekdays[] = { wxTRANSLATE("Mon"), ..., wxTRANSLATE("Sun") }; ... // use wxGetTranslation(weekdays[n])here.
Note that although the code would compile if you simply omit wxTRANSLATE() in the above, it wouldn't work as expected because there would be no translations for the weekday names in the program message catalog and wxGetTranslation wouldn't find them.
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
const wxChar * _(const char *s)
This macro expands into a call to wxGetTranslation function, so it marks the message for the extraction by xgettext just as wxTRANSLATE does, but also returns the translation of the string for the current locale during execution.
Don't confuse this macro with _T()!
wxChar _T(char ch)
const wxChar * _T(const wxChar ch)
This macro is exactly the same as wxT and is defined in wxWidgets simply because it may be more intuitive for Windows programmers as the standard Win32 headers also define it (as well as yet another name for the same macro which is _TEXT()).
Don't confuse this macro with _()!