32 #ifndef _UCOMMON_UNICODE_H_
33 #define _UCOMMON_UNICODE_H_
35 #ifndef _UCOMMON_STRING_H_
73 static const char *
nil;
80 static unsigned size(
const char *codepoint);
87 static size_t count(
const char *
string);
95 static char *offset(
char *
string, ssize_t position);
102 static ucs4_t codepoint(
const char *encoded);
109 static size_t chars(
const unicode_t string);
116 static size_t chars(
ucs4_t character);
138 static ucs4_t *udup(
const char *
string);
143 static ucs2_t *wdup(
const char *
string);
152 static const char *find(
const char *
string,
ucs4_t character,
size_t start = 0);
161 static const char *rfind(
const char *
string,
ucs4_t character,
size_t end = (
size_t)-1l);
169 static unsigned ccount(
const char *
string,
ucs4_t character);
284 {
return get(unicode,
size);};
454 inline operator bool()
const
455 {
return text != NULL;};
462 {
return text == NULL;};
469 ucs4_t operator[](
long codepoint)
const;
494 {
return (
const char *)text == string;};
502 {
return (
const char *)text != string;};
509 {
return utf8::codepoint((
const char *)text);};
516 {
return (
char *)text;};
522 inline operator char*()
const
523 {
return (
char *)text;};
529 inline size_t len(
void)
const
530 {
return utf8::count((
const char *)text);};
533 inline ucs4_t *strudup(
const char *
string)
534 {
return utf8::udup(
string);}
536 inline ucs2_t *strwdup(
const char *
string)
537 {
return utf8::wdup(
string);}
539 __EXPORT
unicode_t unidup(
const char *
string);
542 inline void dupfree<ucs2_t*>(
ucs2_t *string)
546 inline void dupfree<ucs4_t*>(
ucs4_t *string)
550 inline void dupfree<unicode_t>(
unicode_t string)
bool operator==(const char *string) const
check if pointer equals another string.
utf8_pointer utf8_t
Convenience type for utf8_pointer strings.
static ucs4_t codepoint(const char *encoded)
Convert a utf8 encoded codepoint to a ucs4 character value.
strsize_t count(void) const
Count codepoints in current string.
size_t len(void) const
Get length of null terminated utf8 string in codepoints.
char at(int position) const
Return character found at a specific position in the string.
A core class of ut8 encoded string functions.
void cut(strsize_t offset, strsize_t size=0)
Cut (remove) text from string.
String operator()(int offset, strsize_t size) const
Get a new substring through object expression.
int32_t ucs4_t
32 bit unicode character code.
A copy-on-write string class that operates by reference count.
UString left(strsize_t size) const
Convenience method for left of string.
size_t operator()(unicode_t unicode, size_t size) const
Extract a unicode byte sequence from utf8 object.
strsize_t size(void) const
Get the size of currently allocated space for string.
static const char * nil
A convenient NULL pointer value.
UString right(strsize_t offset) const
Convenience method for right of string.
void paste(strsize_t offset, const char *text, strsize_t size=0)
Insert (paste) text into string.
void set(const char *text)
Set string object to text of a null terminated string.
ucs4_t operator*() const
Get unicode character pointed to by pointer.
ucs4_t at(int position) const
Return unicode character found at a specific codepoint in the string.
const char * find(const char *list, strsize_t offset=0) const
Find a character in the string.
UString copy(strsize_t offset, strsize_t size) const
Convenience method for substring extraction.
void start(JoinableThread *thread, int priority=0)
Convenience function to start a joinable thread.
bool operator!() const
Check if text is an invalid pointer.
A common string class and character string support functions.
void * unicode_t
Resolves issues where wchar_t is not defined.
A copy-on-write utf8 string class that operates by reference count.
const char * rfind(const char *list, strsize_t offset=npos) const
Find last occurrence of character in the string.
strsize_t ccount(const char *list) const
Count number of occurrences of characters in string.
Common character processing protocol.
void add(const char *text)
Append null terminated text to our string buffer.
unsigned short strsize_t
A convenience class for size of strings.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
static const unsigned ucsize
Size of "unicode_t" character codes, may not be ucs4_t size.
bool operator!=(const char *string) const
check if pointer does not equal another string.
ucs4_t operator[](int position) const
Reference a unicode character in string object by array offset.
Pointer to utf8 encoded character data.
UString ustring_t
Convenience type for utf8 encoded strings.
static size_t count(const char *string)
Count ut8 encoded ucs4 codepoints in string.
char * c_str(void) const
Get c string we point to.
int16_t ucs2_t
16 bit unicode character code.