![]() |
#include <UString.h>
Public Types | |
enum | TextEncoding { e_ascii_enc = 0, e_pdfdoc_enc, e_winansii_enc, e_pdftext_enc, e_utf16be_enc, e_utf8, e_no_enc } |
A descriptor for the 8-bit character buffer encoding. More... | |
Public Member Functions | |
UString () | |
Create an empty string. | |
UString (const UString &str) | |
Create a new string from UString. | |
UString (Unicode value) | |
Create a new string from a single Unicode character. | |
UString (const Unicode *value) | |
Create a new string from a Unicode character buffer array. | |
UString (const Unicode *value, int length) | |
Create a new string from a Unicode character buffer array. | |
UString (const char *buf, int buf_sz=-1, TextEncoding enc=e_ascii_enc) | |
Create a new string from a 8-bit character buffer array. | |
~UString () | |
Destructor. | |
UString & | operator= (const UString &str) |
Assign a new string. | |
UString & | operator= (const char *ascii_str) |
UString & | Assign (const UString &uni) |
Assigns new character values to the contents of a string. | |
UString & | Assign (const Unicode *uni, int buf_sz=-1) |
UString & | Assign2 (const char *buf, int buf_sz=-1, TextEncoding enc=e_ascii_enc) |
UString & | operator+= (const UString &str) |
Append a string to this string. | |
UString | Concat (const UString &str) const |
Concatenates the specified string to the end of this string. | |
int | GetLength () const |
Returns the length of this string. | |
bool | Empty () const |
Tests whether the string contains any characters. | |
const Unicode * | GetBuffer () const |
Returns a pointer to the Unicode character buffer from this string. | |
int | Compare (const UString &str, int max_length=-1) const |
Compares two strings. | |
int | Compare (const char *ascii_string, int max_length=-1) const |
Compares two strings. | |
UString | SubStr (int off=0, int count=-1) const |
Unicode | GetAt (int idx) const |
Provides a reference to the character with a specified index in a string. | |
void | PushBack (Unicode ch) |
Adds an element to the end of the string. | |
void | Resize (int count, Unicode ch= ' ') |
Specifies a new size for a string, appending or erasing elements as required. | |
void | ToUpper () |
Converts all characters in a string to uppercase. | |
void | ToLower () |
Converts all characters in a string to lowercase. | |
void | Reserve (int count) |
Sets the capacity of the string to a number at least as great as a specified number. | |
const Unicode * | CStr () const |
Converts the contents of a string as a C-style, null-terminated string. | |
bool | IsInAscii () const |
int | ConvertToAscii (char *in_out_buf, int buf_sz, bool null_term) const |
Convert to ASCII C string. | |
int | ConvertToUtf8 (char *in_out_buf, int buf_sz, bool null_term) const |
Convert to UTF8 C string. | |
std::string | ConvertToAscii () const |
Convert to ASCII std::string. | |
std::string | ConvertToUtf8 () const |
Convert to UTF8 encoded std::string. | |
int | ConvertToPDFText (char *in_out_buf, int buf_sz, bool force_unicode=false) const |
Convert the Unicode string to 'PDF Text' string. | |
Friends | |
UString | operator+ (const UString &str1, const UString &str2) |
bool | operator== (const UString &rStr1, const UString &rStr2) |
bool | operator== (const UString &rStr1, const Unicode *pStr2) |
bool | operator== (const Unicode *pStr1, const UString &rStr2) |
bool | operator!= (const UString &rStr1, const UString &rStr2) |
bool | operator!= (const UString &rStr1, const Unicode *pStr2) |
bool | operator!= (const Unicode *pStr1, const UString &rStr2) |
bool | operator< (const UString &rStr1, const UString &rStr2) |
bool | operator> (const UString &rStr1, const UString &rStr2) |
bool | operator<= (const UString &rStr1, const UString &rStr2) |
bool | operator>= (const UString &rStr1, const UString &rStr2) |
UString-s are usually referred to as strings, but they should not be confused with the null-terminated C-strings.
A descriptor for the 8-bit character buffer encoding.
e_ascii_enc | ASCII encoded text. |
e_pdfdoc_enc | PDFDocEncoding. See Appendix 'D' in PDF Reference. |
e_winansii_enc | WinAnsiiEncoding. See Appendix 'D' in PDF Reference. |
e_pdftext_enc | Text represented as PDF Text (section 3.8.1 'Text Strings' in PDF Reference). |
e_utf16be_enc | UTF-16BE (big-endian) encoding scheme. |
e_utf8 | UTF-8 encoding scheme. |
e_no_enc | No specific encoding. |
pdftron::UString::UString | ( | ) |
Create an empty string.
pdftron::UString::UString | ( | const UString & | str | ) |
pdftron::UString::UString | ( | Unicode | value | ) | [explicit] |
Create a new string from a single Unicode character.
value | a Unicode character. |
pdftron::UString::UString | ( | const Unicode * | value | ) |
Create a new string from a Unicode character buffer array.
value | - a NULL-terminated Unicode character array. |
pdftron::UString::UString | ( | const Unicode * | value, | |
int | length | |||
) |
Create a new string from a Unicode character buffer array.
value | a Unicode character array. | |
length | the number of character which should be copied. The character array length must be greater or equal than this value. |
pdftron::UString::UString | ( | const char * | buf, | |
int | buf_sz = -1 , |
|||
TextEncoding | enc = e_ascii_enc | |||
) |
Create a new string from a 8-bit character buffer array.
value | An 8-bit character array. | |
buf_sz | the number of character which should be converted. The 8-bit character array length must be greater or equal than this value. A negative number means that the string is null terminated. | |
encoding | the text encoding from which the 8-bit character sequence should be converted. |
pdftron::UString::~UString | ( | ) |
Destructor.
UString& pdftron::UString::operator= | ( | const char * | ascii_str | ) |
Assigns new character values to the contents of a string.
UString& pdftron::UString::Assign2 | ( | const char * | buf, | |
int | buf_sz = -1 , |
|||
TextEncoding | enc = e_ascii_enc | |||
) |
Concatenates the specified string to the end of this string.
str | the string that is concatenated to the end of this string. |
int pdftron::UString::GetLength | ( | ) | const |
Returns the length of this string.
The length is equal to the number of Unicode characters in this string.
bool pdftron::UString::Empty | ( | ) | const |
Tests whether the string contains any characters.
const Unicode* pdftron::UString::GetBuffer | ( | ) | const |
Returns a pointer to the Unicode character buffer from this string.
The string is not necessarily NULL terminated.
int pdftron::UString::Compare | ( | const UString & | str, | |
int | max_length = -1 | |||
) | const |
Compares two strings.
The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. This function can't be used for language specific sorting.
str | the object to be compared. | |
max_length | (optional parameter) the maximum count of characters to be compared. Negative number means that the entire string should be compared. |
int pdftron::UString::Compare | ( | const char * | ascii_string, | |
int | max_length = -1 | |||
) | const |
Compares two strings.
The comparison is based on the numeric value of each character in the strings and return a value indicating their relationship. Since this method is optimized for performance, the ASCII character values are not converted in any way. The caller has to make sure that all ASCII characters are in the allowed range between 0 and 127. The ASCII string must be NULL-terminated. This function can't be used for language specific sorting.
ascii_string | the 8-bit ASCII character string to be compared. | |
max_length | (optional parameter) the maximum count of characters to be compared. Negative number means that the entire string should be compared. |
UString pdftron::UString::SubStr | ( | int | off = 0 , |
|
int | count = -1 | |||
) | const |
Unicode pdftron::UString::GetAt | ( | int | idx | ) | const |
Provides a reference to the character with a specified index in a string.
idx | The index of the position of the element to be referenced |
void pdftron::UString::PushBack | ( | Unicode | ch | ) |
Adds an element to the end of the string.
ch | The character to be added to the end of the string. |
void pdftron::UString::Resize | ( | int | count, | |
Unicode | ch = ' ' | |||
) |
Specifies a new size for a string, appending or erasing elements as required.
count | The new size of the string. | |
ch | The value that appended characters are initialized with if additional elements are required. |
void pdftron::UString::ToUpper | ( | ) |
Converts all characters in a string to uppercase.
void pdftron::UString::ToLower | ( | ) |
Converts all characters in a string to lowercase.
void pdftron::UString::Reserve | ( | int | count | ) |
Sets the capacity of the string to a number at least as great as a specified number.
count | The number of characters for which memory is being reserved. |
const Unicode* pdftron::UString::CStr | ( | ) | const |
Converts the contents of a string as a C-style, null-terminated string.
bool pdftron::UString::IsInAscii | ( | ) | const |
int pdftron::UString::ConvertToAscii | ( | char * | in_out_buf, | |
int | buf_sz, | |||
bool | null_term | |||
) | const |
Convert to ASCII C string.
in_out_buf | if NULL the function returns the number of bytes required to store the ASCII string. If in_out_buf is not NULL the function will fill out the buffer with ASCII converted string. | |
buf_sz | Size of the in_out_buf buffer, in bytes. If the length of the converted string exceeds the size that the buf_sz parameter specifies, the string is truncated to buf_sz-1 characters. | |
null_term | to null terminate the converted string set this parameter to true. |
Referenced by pdftron::operator<<().
int pdftron::UString::ConvertToUtf8 | ( | char * | in_out_buf, | |
int | buf_sz, | |||
bool | null_term | |||
) | const |
Convert to UTF8 C string.
in_out_buf | if NULL the function returns the number of bytes required to store the UTF8 string. If in_out_buf is not NULL the function will fill out the buffer with UTF8 converted string. | |
buf_sz | Size of the in_out_buf buffer, in bytes. If the length of the converted string exceeds the size that the buf_sz parameter specifies, the string is truncated to buf_sz-1 characters. | |
null_term | to null terminate the converted string set this parameter to true. |
std::string pdftron::UString::ConvertToAscii | ( | ) | const |
Convert to ASCII std::string.
std::string pdftron::UString::ConvertToUtf8 | ( | ) | const |
Convert to UTF8 encoded std::string.
int pdftron::UString::ConvertToPDFText | ( | char * | in_out_buf, | |
int | buf_sz, | |||
bool | force_unicode = false | |||
) | const |
Convert the Unicode string to 'PDF Text' string.
PDF Text Strings are not used to represent page content, however they are used in text annotations, bookmark names, article names, document information etc. These strings are encoded in either PDFDocEncoding or Unicode character encoding. For more information on PDF Text Strings, please refer to section 3.8.1 'Text Strings' in PDF Reference.
in_out_buf | if NULL the function returns the number of bytes required to store the converted string. If in_out_buf is not NULL the function will fill out the buffer with PDF Text data. | |
buf_sz | Size of the in_out_buf buffer, in bytes. If the length of the converted string exceeds the size that the buf_sz parameter specifies, the string is truncated to buf_sz characters. | |
force_unicode | (optional) If true the string will always be converted as Unicode. If false (which is default) the function will first attempt to encode the sting using PDFDocEncoding. If the string can't be mapped to PDFDocEncoding it will be converted as Unicode. |