33 #ifndef _UCOMMON_UNICODE_H_ 34 #define _UCOMMON_UNICODE_H_ 36 #ifndef _UCOMMON_STRING_H_ 78 static const unsigned ucsize;
83 static const char *
nil;
90 static unsigned size(
const char *codepoint);
97 static size_t count(
const char *
string);
105 static char *offset(
char *
string, ssize_t position);
112 static ucs4_t codepoint(
const char *encoded);
119 static size_t chars(
const unicode_t string);
126 static size_t chars(
ucs4_t character);
134 static size_t unpack(
const unicode_t string,
char *text,
size_t size);
143 static size_t pack(
unicode_t unicode,
const char *cp,
size_t len);
148 static ucs4_t *udup(
const char *
string);
153 static ucs2_t *wdup(
const char *
string);
162 static const char *find(
const char *
string,
ucs4_t character,
size_t start = 0);
171 static const char *rfind(
const char *
string,
ucs4_t character,
size_t end = (
size_t)-1l);
179 static unsigned ccount(
const char *
string,
ucs4_t character);
186 static ucs4_t get(
const char *cp);
194 static void put(
ucs4_t character,
char *buf);
229 UString(
const char *text,
size_t size);
258 UString get(
size_t codepoint,
size_t size = 0)
const;
266 size_t get(
unicode_t unicode,
size_t size)
const;
285 ucs4_t at(
int position)
const;
294 return get(unicode, size);
303 UString operator()(
int codepoint,
size_t size)
const;
311 return operator()(0, size);
320 return operator()(-((
int)offset), 0);
330 return operator()((
int)offset, size);
338 void cut(
size_t offset,
size_t size = 0);
346 void paste(
size_t offset,
const char *text,
size_t size = 0);
355 const char *operator()(
int offset)
const;
379 unsigned ccount(
ucs4_t character)
const;
387 const char *find(
ucs4_t character,
size_t start = 0)
const;
395 const char *rfind(
ucs4_t character,
size_t end = npos)
const;
470 inline operator bool()
const {
487 ucs4_t operator[](
long codepoint)
const;
512 return (
const char *)text == string;
521 return (
const char *)text != string;
544 inline operator char*()
const {
552 inline size_t len(
void)
const {
557 inline ucs4_t *strudup(
const char *
string) {
561 inline ucs2_t *strwdup(
const char *
string) {
565 __EXPORT
unicode_t unidup(
const char *
string);
568 inline void dupfree<ucs2_t*>(
ucs2_t *
string) {
573 inline void dupfree<ucs4_t*>(
ucs4_t *
string) {
578 inline void dupfree<unicode_t>(
unicode_t string) {
ucs4_t at(int position) const
Return unicode character found at a specific codepoint in the string.
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.
char * c_str(void) const
Get c string we point to.
ucs4_t operator[](int position) const
Reference a unicode character in string object by array offset.
size_t operator()(unicode_t unicode, size_t size) const
Extract a unicode byte sequence from utf8 object.
A copy-on-write string class that operates by reference count.
size_t len(void) const
Get length of null terminated utf8 string in codepoints.
static size_t count(const char *string)
Count ut8 encoded ucs4 codepoints in string.
A common string class and character string support functions.
size_t count(void) const
Count codepoints in current string.
int16_t ucs2_t
16 bit unicode character code.
static ucs4_t codepoint(const char *encoded)
Convert a utf8 encoded codepoint to a ucs4 character value.
utf8_pointer utf8_t
Convenience type for utf8_pointer strings.
int32_t ucs4_t
32 bit unicode character code.
A core class of ut8 encoded string functions.
bool operator!() const
Check if text is an invalid pointer.
Common namespace for all ucommon objects.
static ucs4_t * udup(const char *string)
Dup a utf8 string into a ucs4_t string.
T copy(const T &src)
Convenience function to copy objects.
bool operator==(const char *string) const
check if pointer equals another string.
Pointer to utf8 encoded character data.
UString copy(size_t offset, size_t size) const
Convenience method for substring extraction.
static const char * nil
A convenient NULL pointer value.
UString ustring_t
Convenience type for utf8 encoded strings.
bool operator!=(const char *string) const
check if pointer does not equal another string.
void * unicode_t
Resolves issues where wchar_t is not defined.
UString right(size_t offset) const
Convenience method for right of string.
UString left(size_t size) const
Convenience method for left of string.