tsc_UniString
This class implements a simple Unicode (strictly speaking, UTF-16) string object.
It's primary use is to convert between UTF-8 strings, which the Survey Core API uses extensively, and "wide" unicode strings that many Windows API methods require.
Example - calling a "wide" Windows API function using tsc_Strings
bool SetEnvironmentVar (tsc_String name, tsc_String value)
{
return ::SetEnvironmentVariableW (
tsc_UniString(name).ToCharacters(), tsc_UniString(value).ToCharacters() );
}
Constructors
tsc_UniString (); Constructs an empty string.
tsc_UniString (const tsc_UniString& uniStr); Constructs a unicode string from a tsc_UniString.
tsc_UniString (const tsc_String& s); Constructs a unicode string from a tsc_String.
tsc_UniString (const wchar_t* s); Constructs a unicode string from a pointer to a wide string.
tsc_UniString (wchar_t c); Constructs a unicode string from a wide character.
Operators
tsc_UniString& operator = (const tsc_UniString& uniStr); Assignment from a tsc_UniString.
tsc_UniString& operator = (const tsc_String& str); Assignment from a tsc_String.
tsc_UniString& operator = (wchar_t c); Assignment from a wide character.
tsc_UniString& operator = (const wchar_t* s); Assignment from a wide character string.
wchar_t operator [] (int index) const; [] operator for indexing into the string (read only).
Other methods
int Length () const; Returns the number of wide characters, not the number of bytes
bool IsEmpty () const; Returns true if the string length is zero.
Conversions
virtual tsc_String ToString () const;
Converts a unicode string to a tsc_String (UTF-8).
const wchar_t* ToCharacters() const;
Returns a unicode string as a wide pointer. Note that the returned value points to an internal buffer in the tsc_UniString object, and is only valid as long as the object exists.
static const tsc_UniString Empty;
An empty unicode string.