33 #ifndef _UCOMMON_UNICODE_H_
34 #define _UCOMMON_UNICODE_H_
36 #ifndef _UCOMMON_STRING_H_
78 static const char *
nil;
85 static unsigned size(
const char *codepoint);
92 static size_t count(
const char *
string);
100 static char *offset(
char *
string, ssize_t position);
107 static ucs4_t codepoint(
const char *encoded);
114 static size_t chars(
const unicode_t
string);
121 static size_t chars(ucs4_t character);
143 static ucs4_t *udup(
const char *
string);
148 static ucs2_t *wdup(
const char *
string);
157 static const char *find(
const char *
string, ucs4_t character,
size_t start = 0);
166 static const char *rfind(
const char *
string, ucs4_t character,
size_t end = (
size_t)-1l);
174 static unsigned ccount(
const char *
string, ucs4_t character);
232 UString(
const unicode_t *text,
const unicode_t *end);
261 size_t get(unicode_t unicode,
size_t size)
const;
267 void set(
const unicode_t unicode);
273 void add(
const unicode_t unicode);
280 ucs4_t at(
int position)
const;
288 inline size_t operator()(unicode_t unicode,
size_t size)
const
289 {
return get(unicode, size);}
305 {
return operator()(0, size);}
313 {
return operator()(-((
int)offset), 0);}
322 {
return operator()((
int)offset, size);}
346 const char *operator()(
int offset)
const;
368 unsigned ccount(ucs4_t character)
const;
384 const char *rfind(ucs4_t character,
strsize_t end = npos)
const;
459 inline operator bool()
const
460 {
return text != NULL;}
467 {
return text == NULL;}
474 ucs4_t operator[](
long codepoint)
const;
499 {
return (
const char *)text == string;}
507 {
return (
const char *)text != string;}
521 {
return (
char *)text;}
527 inline operator char*()
const
528 {
return (
char *)text;}
534 inline size_t len(
void)
const
538 inline ucs4_t *strudup(
const char *
string)
541 inline ucs2_t *strwdup(
const char *
string)
544 __EXPORT unicode_t unidup(
const char *
string);
547 inline void dupfree<ucs2_t*>(ucs2_t *string)
551 inline void dupfree<ucs4_t*>(ucs4_t *string)
555 inline void dupfree<unicode_t>(unicode_t string)
static const char * nil
A convenient NULL pointer value.
A common string class and character string support functions.
A core class of ut8 encoded string functions.
ucs4_t operator*() const
Get unicode character pointed to by pointer.
UString right(strsize_t offset) const
Convenience method for right of string.
static size_t count(const char *string)
Count ut8 encoded ucs4 codepoints in string.
bool operator!=(const char *string) const
check if pointer does not equal another string.
bool operator==(const char *string) const
check if pointer equals another string.
int16_t ucs2_t
16 bit unicode character code.
UString copy(strsize_t offset, strsize_t size) const
Convenience method for substring extraction.
A copy-on-write utf8 string class that operates by reference count.
unsigned short strsize_t
A convenience class for size of strings.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
A copy-on-write string class that operates by reference count.
ucs4_t at(int position) const
Return unicode character found at a specific codepoint in the string.
int32_t ucs4_t
32 bit unicode character code.
static ucs4_t * udup(const char *string)
Dup a utf8 string into a ucs4_t string.
UString ustring_t
Convenience type for utf8 encoded strings.
static const unsigned ucsize
Size of "unicode_t" character codes, may not be ucs4_t size.
void * unicode_t
Resolves issues where wchar_t is not defined.
ucs4_t operator[](int position) const
Reference a unicode character in string object by array offset.
Common namespace for all ucommon objects.
static ucs4_t codepoint(const char *encoded)
Convert a utf8 encoded codepoint to a ucs4 character value.
size_t operator()(unicode_t unicode, size_t size) const
Extract a unicode byte sequence from utf8 object.
Pointer to utf8 encoded character data.
bool operator!() const
Check if text is an invalid pointer.
static ucs2_t * wdup(const char *string)
Dup a utf8 string into a ucs2_t representation.
utf8_pointer utf8_t
Convenience type for utf8_pointer strings.
size_t len(void) const
Get length of null terminated utf8 string in codepoints.
void start(JoinableThread *thread, int priority=0)
Convenience function to start a joinable thread.
char * c_str(void) const
Get c string we point to.
UString left(strsize_t size) const
Convenience method for left of string.
strsize_t count(void) const
Count codepoints in current string.
Common character processing protocol.