unsigned int ByteLength() const {return m_byteLength;}
unsigned int Length() const {return m_charLength;}
unsigned int ByteLengthTo(int charOffset);
int IsEmpty();
Notice that the first two functions are called ByteLength() and Length(). If you
remember, CPStrings are made to hold single-byte or multiple-byte characters. This
means that a string’s byte length is not always equal to its character length. Be
careful when allocating a string to use ByteLength() and not Length().
ByteLengthTo() converts a character offset to a byte offset and IsEmpty() returns a 1 if
the string is not empty.
For example usage of some of these functions, take a look at the following code:
CP_CHAR multi[3]={0xEE,0x6E,0};
CPString str1((PEGCHAR*)multi); //multi-byte character
CPString str2("2");
int j;
j = str1.ByteLength(); // j=2
j = str1.Length()); // j=1
j = str2.ByteLength(); // j=1
j = str2.Length(); // j=1
You can change the case of a string with the following functions:
void ToggleCase();
void UpperCase();
void LowerCase();
You can return the substring of a string by using the Mid() or Left() :
CPString Mid(int charOffset);
CPString Left(int charOffset);
Left() returns a sub-string from the beginning of the string to the character offset
charOffset. Whereas Mid() extracts a sub-string from the end of the string to the
character offset charOffset.
To clear the contents of a CPString use:
void Clear();
Finally, you can replace all of the occurrences of a character in a CPString with:
void ReplaceCharacter(CPMCHAR c0, CPMCHAR c1);
101