#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 } |
Public Member Functions | |
UString () | |
UString (const UString &str) | |
UString (Unicode value) | |
UString (const Unicode *value) | |
UString (const Unicode *value, int length) | |
UString (const char *buf, int buf_sz=-1, TextEncoding enc=e_utf8) | |
UString (const std::string &str, TextEncoding enc=e_utf8) | |
UString (const std::wstring &value) | |
~UString () | |
UString & | operator= (const UString &str) |
UString & | operator= (const char *ascii_str) |
UString & | Assign (const UString &uni) |
UString & | Assign (const Unicode *uni, int buf_sz=-1) |
UString & | Assign2 (const char *buf, int buf_sz=-1, TextEncoding enc=e_utf8) |
UString & | operator+= (const UString &str) |
UString | Concat (const UString &str) const |
int | GetLength () const |
bool | Empty () const |
const Unicode * | GetBuffer () const |
int | Compare (const UString &str, int max_length=-1) const |
UString | SubStr (int off=0, int count=-1) const |
Unicode | GetAt (int idx) const |
void | PushBack (Unicode ch) |
void | Resize (int count, Unicode ch= ' ') |
void | ToUpper () |
void | ToLower () |
void | Reserve (int count) |
const Unicode * | CStr () const |
bool | IsInAscii () const |
int | ConvertToAscii (char *in_out_buf, int buf_sz, bool null_term) const |
int | ConvertToUtf8 (char *in_out_buf, int buf_sz, bool null_term) const |
int | ConvertToUtf32 (UInt32 *in_out_buf, int buf_sz, bool null_term) const |
std::wstring | ConvertToNativeWString () const |
std::string | ConvertToAscii () const |
std::string | ConvertToUtf8 () const |
std::basic_string< UInt32 > | ConvertToUtf32 () const |
int | ConvertToPDFText (char *in_out_buf, int buf_sz, bool force_unicode=false) const |
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) |
Represents text as a series of Unicode characters.
A descriptor for the 8-bit character buffer encoding
Enumerator | |
---|---|
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 | ) |
|
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_utf8 |
||
) |
Create a new string from a 8-bit character buffer array.
buf | 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. |
enc | the text encoding from which the 8-bit character sequence should be converted. |
pdftron::UString::UString | ( | const std::string & | str, |
TextEncoding | enc = e_utf8 |
||
) |
Create a new string from a 8-bit std::string
str | An 8-bit std::string. |
enc | the text encoding from which the 8-bit character sequence should be converted. |
pdftron::UString::UString | ( | const std::wstring & | value | ) |
Create a new string from a wide string native to the current compiler.
value | a string which will be converted to a new UString. |
pdftron::UString::~UString | ( | ) |
Destructor
Assigns new character values to the contents of a string.
UString& pdftron::UString::Assign2 | ( | const char * | buf, |
int | buf_sz = -1 , |
||
TextEncoding | enc = e_utf8 |
||
) |
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. |
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::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. |
std::string pdftron::UString::ConvertToAscii | ( | ) | const |
Convert to ASCII std::string.
std::wstring pdftron::UString::ConvertToNativeWString | ( | ) | const |
Convert to std::wstring that is in the native representation of the current platform.
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. |
int pdftron::UString::ConvertToUtf32 | ( | UInt32 * | in_out_buf, |
int | buf_sz, | ||
bool | null_term | ||
) | const |
Convert to UTF32 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 UTF32 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::basic_string<UInt32> pdftron::UString::ConvertToUtf32 | ( | ) | const |
Convert to UTF32 encoded std::string.
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::ConvertToUtf8 | ( | ) | const |
Convert to UTF8 encoded std::string.
const Unicode* pdftron::UString::CStr | ( | ) | const |
Returns the contents of a UString as a C-style, null-terminated Unicode string.
bool pdftron::UString::Empty | ( | ) | const |
Tests whether the string contains any characters.
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 |
The first element of the string has an index of zero and the following elements are indexed consecutively by the positive integers.
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::GetLength | ( | ) | const |
Returns the length of this string. The length is equal to the number of Unicode characters in this string.
bool pdftron::UString::IsInAscii | ( | ) | const |
Append a string to this string.
str | a UString to append to this string. |
Assign a new string.
str | a UString. |
UString& pdftron::UString::operator= | ( | const char * | ascii_str | ) |
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::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. |
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. |
UString pdftron::UString::SubStr | ( | int | off = 0 , |
int | count = -1 |
||
) | const |
Copies a substring of at most some number of characters from a string beginning from a specified position.
off | An index locating the element at the position from which the copy of the string is made, with a default value of 0. |
count | The number of characters that are to be copied if they are present. -1 means copy the entire string. |
void pdftron::UString::ToLower | ( | ) |
Converts all characters in a string to lowercase.
void pdftron::UString::ToUpper | ( | ) |
Converts all characters in a string to uppercase.