32 #ifndef _UCOMMON_UNICODE_H_
33 #define _UCOMMON_UNICODE_H_
35 #ifndef _UCOMMON_STRING_H_
77 static const char *
nil;
84 static unsigned size(
const char *codepoint);
91 static size_t count(
const char *
string);
99 static char *offset(
char *
string, ssize_t position);
106 static ucs4_t codepoint(
const char *encoded);
113 static size_t chars(
const unicode_t
string);
120 static size_t chars(ucs4_t character);
142 static ucs4_t *udup(
const char *
string);
147 static ucs2_t *wdup(
const char *
string);
156 static const char *find(
const char *
string, ucs4_t character,
size_t start = 0);
165 static const char *rfind(
const char *
string, ucs4_t character,
size_t end = (
size_t)-1l);
173 static unsigned ccount(
const char *
string, ucs4_t character);
231 UString(
const unicode_t *text,
const unicode_t *end);
260 size_t get(unicode_t unicode,
size_t size)
const;
266 void set(
const unicode_t unicode);
272 void add(
const unicode_t unicode);
279 ucs4_t at(
int position)
const;
287 inline size_t operator()(unicode_t unicode,
size_t size)
const
288 {
return get(unicode, size);}
304 {
return operator()(0, size);}
312 {
return operator()(-((
int)offset), 0);}
321 {
return operator()((
int)offset, size);}
345 const char *operator()(
int offset)
const;
367 unsigned ccount(ucs4_t character)
const;
383 const char *rfind(ucs4_t character,
strsize_t end = npos)
const;
458 inline operator bool()
const
459 {
return text != NULL;}
466 {
return text == NULL;}
473 ucs4_t operator[](
long codepoint)
const;
498 {
return (
const char *)text == string;}
506 {
return (
const char *)text != string;}
520 {
return (
char *)text;}
526 inline operator char*()
const
527 {
return (
char *)text;}
533 inline size_t len(
void)
const
537 inline ucs4_t *strudup(
const char *
string)
540 inline ucs2_t *strwdup(
const char *
string)
543 __EXPORT unicode_t unidup(
const char *
string);
546 inline void dupfree<ucs2_t*>(ucs2_t *string)
550 inline void dupfree<ucs4_t*>(ucs4_t *string)
554 inline void dupfree<unicode_t>(unicode_t string)
UString ustring_t
Convenience type for utf8 encoded strings.
ucs4_t at(int position) const
Return unicode character found at a specific codepoint in the string.
static const unsigned ucsize
Size of "unicode_t" character codes, may not be ucs4_t size.
A copy-on-write string class that operates by reference count.
static size_t count(const char *string)
Count ut8 encoded ucs4 codepoints in string.
int16_t ucs2_t
16 bit unicode character code.
Common namespace for all ucommon objects.
strsize_t count(void) const
Count codepoints in current string.
utf8_pointer utf8_t
Convenience type for utf8_pointer strings.
Pointer to utf8 encoded character data.
bool operator!=(const char *string) const
check if pointer does not equal another string.
Common character processing protocol.
static ucs2_t * wdup(const char *string)
Dup a utf8 string into a ucs2_t representation.
A copy-on-write utf8 string class that operates by reference count.
bool operator==(const char *string) const
check if pointer equals another string.
static ucs4_t * udup(const char *string)
Dup a utf8 string into a ucs4_t string.
int32_t ucs4_t
32 bit unicode character code.
unsigned short strsize_t
A convenience class for size of strings.
size_t len(void) const
Get length of null terminated utf8 string in codepoints.
ucs4_t operator[](int position) const
Reference a unicode character in string object by array offset.
A core class of ut8 encoded string functions.
size_t operator()(unicode_t unicode, size_t size) const
Extract a unicode byte sequence from utf8 object.
static const char * nil
A convenient NULL pointer value.
static ucs4_t codepoint(const char *encoded)
Convert a utf8 encoded codepoint to a ucs4 character value.
void start(JoinableThread *thread, int priority=0)
Convenience function to start a joinable thread.
ucs4_t operator*() const
Get unicode character pointed to by pointer.
void * unicode_t
Resolves issues where wchar_t is not defined.
UString left(strsize_t size) const
Convenience method for left of string.
UString right(strsize_t offset) const
Convenience method for right of string.
bool operator!() const
Check if text is an invalid pointer.
UString copy(strsize_t offset, strsize_t size) const
Convenience method for substring extraction.
A common string class and character string support functions.
char * c_str(void) const
Get c string we point to.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.