10 #define __AFW_UTF8_H__
94 } afw_utf8_nfc_option_t;
114 afw_utf8_nfc_option_t option,
154 #define afw_utf8_is_valid(s, len, xctx) \
155 (afw_utf8_nfc(s, len, afw_utf8_nfc_option_is_valid, \
156 (xctx)->p, xctx) == NULL)
168 #define afw_utf8_is_nfc(s, len, p, xctx) \
169 (afw_utf8_nfc(s, len, afw_utf8_nfc_option_is_nfc, \
239 #define afw_utf8_create(s,len, p, xctx) \
240 afw_utf8_nfc(s, len, afw_utf8_nfc_option_create, p, xctx)
254 #define afw_utf8_from_utf8_z(s_z, p, xctx) \
255 afw_utf8_nfc(s_z, AFW_UTF8_Z_LEN, afw_utf8_nfc_option_create, \
369 #define afw_utf8_create_copy(s, len, p, xctx) \
370 afw_utf8_nfc(s, len, afw_utf8_nfc_option_create_copy, p, xctx)
535 memcpy(result, string->s, string->len);
536 result[
string->len] = 0;
693 AFW_DEFINE_STATIC_INLINE(
void)
698 if (end > string->len) end =
string->len;
699 result->len = (end > start) ? end - start : 0;
700 result->s = (result->len > 0) ? string->s + start : NULL;
736 if (len1-- <= 0 || *s1 != *s2_z) {
760 if (!*s1_z || *s1_z != *s2_z) {
776 AFW_DEFINE_STATIC_INLINE(
int)
783 a1.len = s1 ? strlen(s1): 0;
786 a2.len = s2 ? strlen(s2): 0;
802 return (s1 && s2 && (strcmp((
const char *)s1, (
const char *)s2) == 0
803 || s1 == s2)) ? TRUE : FALSE;
820 return (strcasecmp((
const char *)s1, (
const char *)s2) == 0) ? true :
false;
860 va_start(ap, format_z);
879 if (!path_z)
return "";
881 for (c = file_name = path_z; *c; c++) {
882 if ((*c ==
'/') || (*c ==
'\\')) {
#define AFW_DECLARE_ELLIPSIS(type)
Declare a public afw function with variable arguments.
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE(type)
Declare a public afw function.
Adaptive Framework Minimal Header.
afw_int32_t afw_code_point_t
Unicode code point.
afw_utf8_octet_t afw_utf8_z_t
NFC normalized UTF-8 null terminated string.
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
apr_size_t afw_size_t
size_t.
#define afw_pool_malloc(instance, size, xctx)
Call method malloc of interface afw_pool.
const afw_utf8_t * afw_utf8_concat(const afw_pool_t *p, afw_xctx_t *xctx,...)
Concatenate strings with result in specifed pool.
const afw_memory_t * afw_utf8_as_raw(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Convert utf-8 string to raw in specified pool.
afw_boolean_t afw_utf8_equal_utf8_z(const afw_utf8_t *s1, const afw_utf8_z_t *s2_z)
Check to see if a string equals a utf8_z string.
void afw_utf8_stream_get_current_cached_string(const afw_stream_t *stream, afw_utf8_t *current_cached_string, afw_xctx_t *xctx)
Get the current string in a UTF-8 writer.
int afw_utf8_compare(const afw_utf8_t *s1, const afw_utf8_t *s2)
Compare two strings.
const afw_object_t * afw_utf8_z_query_string_to_object(const afw_utf8_z_t *s, afw_xctx_t *xctx)
void afw_utf8_writer_current_string(const afw_writer_t *writer, afw_utf8_t *current_string, afw_xctx_t *xctx)
Get the current string in a UTF-8 writer.
const afw_utf8_t * afw_utf8_nfc(const afw_utf8_octet_t *s, afw_size_t len, afw_utf8_nfc_option_t option, const afw_pool_t *p, afw_xctx_t *xctx)
UTF-8 NFC support function.
afw_boolean_t afw_utf8_ends_with(const afw_utf8_t *string, const afw_utf8_t *ends_with)
Check to see if a string ends with another string.
afw_boolean_t afw_utf8_starts_with_z(const afw_utf8_t *string, const afw_utf8_z_t *starts_with_z)
Check to see if a string starts with a utf8_z string.
const afw_utf8_t * afw_utf8_from_encoding(const afw_utf8_t *from_encoding, const char **from, afw_size_t *from_size, const afw_pool_t *p, afw_xctx_t *xctx)
Convert character encoding to a utf-8 in specified pool.
const afw_utf8_t * afw_utf8_from_raw(const afw_memory_t *raw, const afw_pool_t *p, afw_xctx_t *xctx)
Convert raw to a utf-8 NFC normalizing if necessary in specified pool.
afw_boolean_t afw_utf8_ends_with_z(const afw_utf8_t *string, const afw_utf8_z_t *ends_with_z)
Check to see if a string ends with a utf8_z string.
const afw_utf8_z_t * afw_utf8_z_printf_v(const afw_utf8_z_t *format_z, va_list ap, const afw_pool_t *p, afw_xctx_t *xctx)
const afw_utf8_t * afw_utf8_printf_v(const afw_utf8_z_t *format, va_list arg, const afw_pool_t *p, afw_xctx_t *xctx)
Create a utf-8 string using a c format string in specified pool.
afw_boolean_t afw_utf8_z_equal_ignore_case(const afw_utf8_z_t *s1, const afw_utf8_z_t *s2)
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
afw_boolean_t afw_utf8_from_code_point(afw_utf8_octet_t utf8_z[5], afw_code_point_t cp, afw_xctx_t *xctx)
Convert a code point to utf8.
const afw_utf8_t *const * afw_utf8_parse_csv(const afw_utf8_t *s, const afw_pool_t *p, afw_xctx_t *xctx)
Check to see if a string equals a utf8_z string.
const afw_utf8_t *const * afw_utf8_clone_pointer_array(afw_size_t count, const afw_utf8_t *const *pointers, afw_boolean_t NULL_terminate, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a pointer array of utf-8 to specified pool.
afw_boolean_t afw_utf8_z_starts_with_z(const afw_utf8_z_t *s1_z, const afw_utf8_z_t *s2_z)
Returns true if zero terminated s1 starts with zero terminated string s2.
afw_boolean_t afw_utf8_line_column_of_offset(afw_size_t *line_number, afw_size_t *column_number, const afw_utf8_t *s, afw_size_t offset, int tab_size, afw_xctx_t *xctx)
Determine the line and column of an offset in a string.
const afw_utf8_z_t * afw_utf8_z_printf(const afw_pool_t *p, afw_xctx_t *xctx, const afw_utf8_z_t *format_z,...)
int afw_utf8_compare_ignore_case(const afw_utf8_t *s1, const afw_utf8_t *s2, afw_xctx_t *xctx)
Compare two strings ignoring case.
const afw_utf8_z_t * afw_utf8_array_to_utf8_z_with_separator(const afw_utf8_t *const *strings, const afw_utf8_t *separator, const afw_pool_t *p, afw_xctx_t *xctx)
Concat array of utf-8 with optional separator to specified pool.
const afw_utf8_z_t * afw_utf8_z_create(const afw_utf8_octet_t *s, afw_size_t len, const afw_pool_t *p, afw_xctx_t *xctx)
Create a NFC Normalized zero terminated UTF-8 string in specified pool.
void afw_utf8_substring_byte(afw_utf8_t *result, const afw_utf8_t *string, afw_size_t start, afw_size_t end)
Set result to a substring of string using byte indexes.
void afw_utf8_line_count_and_max_column(afw_size_t *number_of_lines, afw_size_t *max_column_number, const afw_utf8_t *s, int tab_size, afw_xctx_t *xctx)
Determine the line count and maximum column in a string.
const afw_writer_t * afw_utf8_writer_create(const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
Create UTF-8 writer.
const afw_utf8_t * afw_utf8_clone(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a utf-8 string into a specific pool.
afw_boolean_t afw_utf8_len_starts_with_z(const afw_utf8_octet_t *s1, afw_size_t len1, const afw_utf8_z_t *s2_z)
Returns true if series of bytes for len s1 starts with zero terminated string s2.
const afw_value_t *(AFW_CALLBACK * afw_utf8_to_value_t)(const afw_utf8_t *from_utf8, const afw_utf8_t *path, afw_xctx_t *xctx)
Callback function for converting a string to an adaptive value.
const afw_utf8_z_t * afw_utf8_z_file_name_from_path(const afw_utf8_z_t *path_z)
const afw_utf8_z_t * afw_utf8_to_utf8_z(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Convert utf8 to utf8_z in specified pool.
int afw_utf8_z_compare_ignore_case(const afw_utf8_z_t *s1, const afw_utf8_z_t *s2, afw_xctx_t *xctx)
Compare two zero terminated utf-8 strings ignoring case.
const afw_stream_t * afw_utf8_stream_create(const afw_utf8_t *streamId, const afw_pool_t *p, afw_xctx_t *xctx)
Create UTF-8 stream.
const afw_utf8_z_t * afw_utf8_z_concat(const afw_pool_t *p, afw_xctx_t *xctx,...)
const afw_utf8_t * afw_utf8_printf(const afw_pool_t *p, afw_xctx_t *xctx, const afw_utf8_z_t *format_z,...)
Create a utf-8 string using a c format string in specified pool.
afw_boolean_t afw_utf8_contains(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string contains another string.
const afw_utf8_t * afw_utf8_normalize_space(const afw_utf8_t *s, const afw_pool_t *p, afw_xctx_t *xctx)
Create a utf-8 sting with spaces normalized in specified pool.
afw_boolean_t afw_utf8_z_equal(const afw_utf8_z_t *s1, const afw_utf8_z_t *s2)
const afw_utf8_z_t * afw_utf8_z_array_to_utf8_z_with_separator(const afw_utf8_z_t *const *strings_z, const afw_utf8_t *separator, const afw_pool_t *p, afw_xctx_t *xctx)
Concat array of utf-8 with optional separator to specified pool.
const afw_utf8_t * afw_utf8_to_lower(const afw_utf8_t *s, const afw_pool_t *p, afw_xctx_t *xctx)
Convert utf-8 sting to lower case in specified pool.
afw_boolean_t afw_utf8_starts_with(const afw_utf8_t *string, const afw_utf8_t *starts_with)
Check to see if a string starts with another string.
afw_code_point_t afw_utf8_next_code_point(const afw_utf8_octet_t *s, afw_size_t *offset, afw_size_t len, afw_xctx_t *xctx)
Get next codepoint in utf-8.
const afw_utf8_t * afw_utf8_concat_v(const afw_pool_t *p, afw_xctx_t *xctx, va_list strings)
Concatenate strings with result in specifed pool.
const afw_utf8_t *(AFW_CALLBACK * afw_utf8_from_value_t)(const afw_value_t *value, afw_boolean_t own, afw_xctx_t *xctx)
Callback function for creating a string from an adaptive value.
const afw_utf8_t * afw_utf8_array_to_utf8_with_separator(const afw_utf8_t *const *strings, const afw_utf8_t *separator, const afw_pool_t *p, afw_xctx_t *xctx)
Concat array of utf-8 with optional separator to specified pool.
const afw_utf8_z_t * afw_utf8_z_source_file(const afw_utf8_z_t *source_z)
Returns value of source_z after last '/ 'or '\'.
@ afw_utf8_nfc_option_is_valid
Only check that input is valid UTF-8.
@ afw_utf8_nfc_option_create
If s is already normalized, use it directly for result->s.
@ afw_utf8_nfc_option_create_copy
If s is already normalized, make copy for result->s.
@ afw_utf8_nfc_option_is_nfc
Only check that input is UTF-8 NFC normalized.
Struct for memory pointer and size.
Interface afw_object public struct.
Interface afw_pool public struct.
Interface afw_stream public struct.
NFC normalized UTF-8 string.
Interface afw_value public struct.
Interface afw_writer public struct.
Interface afw_xctx public struct.