Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Files | Macros | Typedefs | Enumerations | Functions

Files

file  afw_utf8.h
 AFW String functions.
 

Macros

#define afw_utf8_is_valid(s, len, xctx)
 Determine if series of bytes is valid utf-8. More...
 
#define afw_utf8_is_nfc(s, len, p, xctx)
 Determine if series of bytes is NFC normalized utf-8. More...
 
#define afw_utf8_create(s, len, p, xctx)    afw_utf8_nfc(s, len, afw_utf8_nfc_option_create, p, xctx)
 Create utf-8 string without copy unless necessary in pool specified. More...
 
#define afw_utf8_from_utf8_z(s_z, p, xctx)
 Make utf-8 string without copy in specified pool. More...
 
#define afw_utf8_create_copy(s, len, p, xctx)    afw_utf8_nfc(s, len, afw_utf8_nfc_option_create_copy, p, xctx)
 Make a utf-8 sting from chars in pool specified. More...
 

Typedefs

typedef 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. More...
 
typedef 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. More...
 
typedef enum afw_utf8_nfc_option_e afw_utf8_nfc_option_t
 

Enumerations

enum  afw_utf8_nfc_option_e { afw_utf8_nfc_option_is_valid , afw_utf8_nfc_option_is_nfc , afw_utf8_nfc_option_create , afw_utf8_nfc_option_create_copy }
 

Functions

const afw_utf8_tafw_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. More...
 
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. More...
 
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. More...
 
const afw_memory_tafw_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. More...
 
const afw_utf8_tafw_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. More...
 
const afw_utf8_tafw_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. More...
 
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. More...
 
const afw_utf8_tafw_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. More...
 
const afw_utf8_z_tafw_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. More...
 
const afw_utf8_z_tafw_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. More...
 
const afw_utf8_tafw_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. More...
 
const afw_utf8_tafw_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. More...
 
const afw_utf8_tafw_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. More...
 
const afw_utf8_tafw_utf8_concat (const afw_pool_t *p, afw_xctx_t *xctx,...)
 Concatenate strings with result in specifed pool. More...
 
const afw_utf8_tafw_utf8_concat_v (const afw_pool_t *p, afw_xctx_t *xctx, va_list strings)
 Concatenate strings with result in specifed pool. More...
 
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. More...
 
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. More...
 
const afw_utf8_tafw_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. More...
 
const afw_utf8_tafw_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. More...
 
const afw_utf8_z_tafw_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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int afw_utf8_compare (const afw_utf8_t *s1, const afw_utf8_t *s2)
 Compare two strings. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const afw_utf8_z_tafw_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. More...
 
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. More...
 
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. More...
 
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.
 
afw_boolean_t afw_utf8_z_equal (const afw_utf8_z_t *s1, const afw_utf8_z_t *s2)
 
afw_boolean_t afw_utf8_z_equal_ignore_case (const afw_utf8_z_t *s1, const afw_utf8_z_t *s2)
 
const afw_utf8_z_tafw_utf8_z_concat (const afw_pool_t *p, afw_xctx_t *xctx,...)
 
const afw_object_tafw_utf8_z_query_string_to_object (const afw_utf8_z_t *s, afw_xctx_t *xctx)
 
const afw_utf8_z_tafw_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_z_tafw_utf8_z_printf (const afw_pool_t *p, afw_xctx_t *xctx, const afw_utf8_z_t *format_z,...)
 
const afw_utf8_z_tafw_utf8_z_file_name_from_path (const afw_utf8_z_t *path_z)
 
const afw_utf8_z_tafw_utf8_z_source_file (const afw_utf8_z_t *source_z)
 Returns value of source_z after last '/ 'or '\'. More...
 
const afw_stream_tafw_utf8_stream_create (const afw_utf8_t *streamId, const afw_pool_t *p, afw_xctx_t *xctx)
 Create UTF-8 stream. More...
 
const afw_writer_tafw_utf8_writer_create (const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
 Create UTF-8 writer. More...
 
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. More...
 
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. More...
 

Detailed Description

All utf8 strings must be valid utf-8.

Macro Definition Documentation

◆ afw_utf8_create

#define afw_utf8_create (   s,
  len,
  p,
  xctx 
)     afw_utf8_nfc(s, len, afw_utf8_nfc_option_create, p, xctx)

Create utf-8 string without copy unless necessary in pool specified.

Parameters
spointer to utf-8 characters.
lenis number of bytes.
ppool used for result.
xctxof caller.
Returns
utf8 string.

This only creates a new afw_string_t struct and sets its values.

The input string will be NFC normalized if it is not already.

Definition at line 239 of file afw_utf8.h.

◆ afw_utf8_create_copy

#define afw_utf8_create_copy (   s,
  len,
  p,
  xctx 
)     afw_utf8_nfc(s, len, afw_utf8_nfc_option_create_copy, p, xctx)

Make a utf-8 sting from chars in pool specified.

Parameters
spointer to chars.
lenof chars in bytes or AFW_UTF8_Z_LEN.
ppool used for result.
xctxof caller.
Returns
utf8 string.

The input string must already be valid utf-8. An error is thrown if it is not.

Definition at line 369 of file afw_utf8.h.

◆ afw_utf8_from_utf8_z

#define afw_utf8_from_utf8_z (   s_z,
  p,
  xctx 
)
Value:
p, xctx)
#define AFW_UTF8_Z_LEN
String is NUL (0) terminate.
Definition: afw_common.h:266
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.
Definition: afw_utf8.c:86
@ afw_utf8_nfc_option_create
If s is already normalized, use it directly for result->s.
Definition: afw_utf8.h:89

Make utf-8 string without copy in specified pool.

Parameters
s_zpointer to zero terminated utf-8 characters.
lenis number of bytes.
ppool used for result.
xctxof caller.
Returns
utf8 string.

The input string will be NFC normalized if it is not already.

Definition at line 254 of file afw_utf8.h.

◆ afw_utf8_is_nfc

#define afw_utf8_is_nfc (   s,
  len,
  p,
  xctx 
)
Value:
p, xctx) == NULL)
@ afw_utf8_nfc_option_is_nfc
Only check that input is UTF-8 NFC normalized.
Definition: afw_utf8.h:86

Determine if series of bytes is NFC normalized utf-8.

Parameters
spointer to bytes to be tested.
lenis number of bytes.
pused if needed for test.
xctxof caller.
Returns
true if valid utf-8 and NFC normalize.

Definition at line 168 of file afw_utf8.h.

◆ afw_utf8_is_valid

#define afw_utf8_is_valid (   s,
  len,
  xctx 
)
Value:
(xctx)->p, xctx) == NULL)
@ afw_utf8_nfc_option_is_valid
Only check that input is valid UTF-8.
Definition: afw_utf8.h:78

Determine if series of bytes is valid utf-8.

Parameters
spointer to bytes to be tested.
lenis number of bytes.
xctxof caller.
Returns
true if valid utf-8.

Definition at line 154 of file afw_utf8.h.

Typedef Documentation

◆ afw_utf8_from_value_t

typedef 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.

Parameters
value
Indicateto only include own properties of any objects.
xctxof caller.
Returns
string

Definition at line 39 of file afw_utf8.h.

◆ afw_utf8_to_value_t

typedef 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.

Parameters
utf-8string to convert.
pathObject path to use if string is an object or NULL.
object_idOptional id of object if value is object or NULL.
xctxof caller.
Returns
value

The path parameter is only used if the string being converted is an object entity.

The path must be of the form /<adaptor id>/<object type>/<id>. This path is parsed to provide return values for the object's afw_object_meta_get_object_id(), afw_object_meta_get_path(), and afw_object_get_object_type() methods.

Definition at line 62 of file afw_utf8.h.

Enumeration Type Documentation

◆ afw_utf8_nfc_option_e

Enumerator
afw_utf8_nfc_option_is_valid 

Only check that input is valid UTF-8.

If input is valid UTF-8 encoding, NULL is returned. Otherwise, a non-NULL pointer is returned.

afw_utf8_nfc_option_is_nfc 

Only check that input is UTF-8 NFC normalized.

If input is valid NFC normalized UTF-8 encoding, NULL is returned. Otherwise, a non-NULL pointer is returned.

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.

Definition at line 70 of file afw_utf8.h.

Function Documentation

◆ afw_utf8_array_to_utf8_with_separator()

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.

Parameters
stringsis NULL terminated list of afw_utf8_t pointers.
separatoror NULL for no separator.
pto use.
xctxof caller.
Returns
utf8 string.

The input strings must already be valid utf-8. An error is thrown if it is not.

Definition at line 906 of file afw_utf8.c.

◆ afw_utf8_array_to_utf8_z_with_separator()

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.

Parameters
stringsis NULL terminated list of afw_utf8_t pointers.
separatoror NULL for no separator.
pto use.
xctxof caller.
Returns
utf8_z 0 terminated string.

The input strings must already be valid utf-8. An error is thrown if it is not.

Definition at line 951 of file afw_utf8.c.

◆ afw_utf8_as_raw()

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.

Parameters
stringto convert.
ppool used for result.
xctxof caller.
Returns
raw

Definition at line 181 of file afw_utf8.h.

◆ afw_utf8_clone()

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.

Parameters
string.
lenis number of bytes.
ppool used for result.
xctxof caller.
Returns
utf8 string.

The input string is assumed to already be valid utf-8.

Definition at line 347 of file afw_utf8.h.

◆ afw_utf8_clone_pointer_array()

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.

Parameters
countis number of pointers or -1 if NULL terminated.
pointersis list of afw_utf8_t pointers.
NULL_terminateindicates resulting array should be NULL terminated.
pto use.
xctxof caller.
Returns
array of afw_utf8_t pointers.

The input strings must already be valid utf-8. An error is thrown if it is not.

Definition at line 862 of file afw_utf8.c.

◆ afw_utf8_compare()

int afw_utf8_compare ( const afw_utf8_t s1,
const afw_utf8_t s2 
)

Compare two strings.

Parameters
s1first string.
s2second string.
Returns
0 if equal, <0 if s1 < s2, >0 if s1 > s2.

The input strings are assumed to already be valid utf-8.

◆ afw_utf8_compare_ignore_case()

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.

Parameters
s1first string.
s2second string.
Returns
0 if equal, <0 if s1 < s2, >0 if s1 > s2.

The input strings are assumed to already be valid utf-8.

◆ afw_utf8_concat()

const afw_utf8_t* afw_utf8_concat ( const afw_pool_t p,
afw_xctx_t xctx,
  ... 
)

Concatenate strings with result in specifed pool.

Parameters
ppool used for result.
xctxof caller.
...1 or more valid utf-8 strings followed with NULL.
Returns
utf8 string.

◆ afw_utf8_concat_v()

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.

Parameters
ppool used for result.
xctxof caller.
va_list1 or more valid utf-8 strings followed with NULL.
Returns
utf8 string.

◆ afw_utf8_contains()

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.

Parameters
s1string.
s2string.
xctxof caller.
Returns
boolean

The input strings are assumed to already be valid utf-8.

Definition at line 543 of file afw_utf8.c.

◆ afw_utf8_ends_with()

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.

Parameters
stringto check.
ends_withstring.
xctxof caller.
Returns
boolean

The input strings are assumed to already be valid utf-8.

Definition at line 513 of file afw_utf8.c.

◆ afw_utf8_ends_with_z()

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.

Parameters
stringto check.
ends_with_z0 terminated string.
xctxof caller.
Returns
boolean

The input strings are assumed to already be valid utf-8.

Definition at line 524 of file afw_utf8.c.

◆ afw_utf8_equal()

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.

Parameters
s1string.
s2string.
xctxof caller.
Returns
boolean

The input strings are assumed to already be valid utf-8.

◆ afw_utf8_equal_utf8_z()

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.

Parameters
s1first string.
s2_zsecond 0 terminated string.
xctxof caller.
Returns
boolean

The input strings are assumed to already be valid utf-8.

◆ afw_utf8_from_code_point()

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.

Parameters
utf8an array of 5 bytes to put result followed by a 0 byte.
cpto convert.
xctxof caller.
Returns
false if cp is not valid.

Definition at line 64 of file afw_utf8.c.

◆ afw_utf8_from_encoding()

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.

Parameters
from_encoding
from
from_size
ppool used for result.
xctxof caller.
Returns
utf8

The raw memory must represent valid utf-8 or an error is thrown.

Definition at line 395 of file afw_utf8.c.

◆ afw_utf8_from_raw()

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.

Parameters
rawvalue to convert.
ppool used for result.
xctxof caller.
Returns
utf8

The raw memory must represent valid utf-8 or an error is thrown.

Definition at line 199 of file afw_utf8.h.

◆ afw_utf8_len_starts_with_z()

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.

Parameters
spointer to utf-8 characters.
len1is number of bytes.
s2_z0 terminated string.
Returns
true or false.

Definition at line 732 of file afw_utf8.h.

◆ afw_utf8_line_column_of_offset()

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.

Parameters
line_numberis return pointer for 1 based line number.
column_numberis return pointer for 1 based column number.
sis string to check.
offsetis offset within string.
tab_sizeto use for '\t'.
xctxof caller.
Returns
false if there were no '
' found.

If there are no '
', line_number will be set to 1 and column_number will be set to offset adjusted by '\t'.

This function does not validity check the string but should produce the correct column number if the string is valid.

Todo:
change this to also return code point offset.

Definition at line 1058 of file afw_utf8.c.

◆ afw_utf8_line_count_and_max_column()

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.

Parameters
number_of_linesis return pointer for 1 based max line number.
max_column_numberis return pointer for 1 based max column number.
sis string to check.
tab_sizeto use for '\t'.
xctxof caller.

This function does not validity check the string but should produce the correct column number if the string is valid.

Todo:
change this to also return octet offset.

Definition at line 1111 of file afw_utf8.c.

◆ afw_utf8_next_code_point()

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.

Parameters
sis pointer to utf-8.
offsetis address of offset in utf-8 string. Will be incremented. @len of s.
xctxof caller.
Returns
codepoint or -1 if invalid.

The offset incremented past the bytes making up the utf-8 codepoint if the codepoint is valid. If you don't want this behavior, make a copy of offset to a temporary variable and past it to function.

Definition at line 31 of file afw_utf8.c.

◆ afw_utf8_nfc()

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.

Parameters
spointer to utf-8 characters.
lenis number of bytes.
optionsee afw_utf8_nfc_option_t.
ppool used for result.
xctxof caller.
Returns
NFC normalized utf8 string or NULL.

See afw_utf8_nfc_option_t for more information.

This function is designed to do as little work as possible to insure that resulting utf8 string is NFC normalize.

Definition at line 86 of file afw_utf8.c.

◆ afw_utf8_normalize_space()

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.

Parameters
sis valid NFC normalized UTF-8 string.
pis pool to use for space normalized string.
xctxof caller.
Returns
lower case utf8 string.

The input string must already be valid NFC utf-8.

If no normalization is required, the input string is returned.

The whitespace character are hex 20, 09, 0d, and 0a. All leading and trailing whitespace characters are removed and internal sequences of whitespace is replaced by a single hex 20.

◆ afw_utf8_parse_csv()

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.

Parameters
sis string that contains comma separated values.
pto use for result.
xctxof caller.
Returns
NULL terminated list of strings.

The input strings are assumed to already be valid utf-8.

Definition at line 1149 of file afw_utf8.c.

◆ afw_utf8_printf()

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.

Parameters
ppool used for result.
xctxof caller.
format_zstring.
...arguments for format_z.
Returns
utf8 string.

Care must be used using this function. No check is made to determine if strings are valid utf-8.

Definition at line 459 of file afw_utf8.c.

◆ afw_utf8_printf_v()

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.

Parameters
format_zstring.
argarguments for format_z.
ppool used for result.
xctxof caller.
Returns
utf8 string.

Care must be used using this function. No check is made to determine if strings are valid utf-8.

Definition at line 477 of file afw_utf8.c.

◆ afw_utf8_starts_with()

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.

Parameters
stringto check.
starts_withstring.
xctxof caller.
Returns
boolean

The input strings are assumed to already be valid utf-8.

◆ afw_utf8_starts_with_z()

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.

Parameters
stringto check.
starts_with_z0 terminated string.
xctxof caller.
Returns
boolean

The input strings are assumed to already be valid utf-8.

◆ afw_utf8_stream_create()

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.

Parameters
streamId
pto use.
xctxof caller.
Returns
stream

Definition at line 52 of file afw_utf8_stream.c.

◆ afw_utf8_stream_get_current_cached_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.

Parameters
writer
currentis address of a afw_utf8_t struct that will be updated.
xctxof caller.

Definition at line 78 of file afw_utf8_stream.c.

◆ afw_utf8_substring_byte()

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.

Parameters
resultpointer to string to be set.
stringinput.
startInclusive zero based start index of substring.
endExclusive end index of substring. If end is beyond end of string, substring will include all bytes up to end of string.

If string might contain codepoints > 127, you should use afw_utf8_substring().

Definition at line 694 of file afw_utf8.h.

◆ afw_utf8_to_lower()

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.

Parameters
sis valid NFC normalized UTF-8 string.
pis pool to use for converted string.
xctxof caller.
Returns
lower case utf8 string.

The input string must already be valid NFC utf-8.

This conversion is not locale specific.

◆ afw_utf8_to_utf8_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.

Parameters
stringto convert.
ppool used for result.
xctxof caller.
Returns
utf8_z 0 terminated string.

The input strings are assumed to already be valid utf-8.

Definition at line 529 of file afw_utf8.h.

◆ afw_utf8_writer_create()

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.

Parameters
tabstring to use or NULL if no whitespace is to be added.
pto use.
xctxof caller.
Returns
writer

Definition at line 52 of file afw_utf8_writer.c.

◆ afw_utf8_writer_current_string()

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.

Parameters
writer
currentis address of a afw_utf8_t struct that will be updated.
xctxof caller.

Definition at line 78 of file afw_utf8_writer.c.

◆ afw_utf8_z_array_to_utf8_z_with_separator()

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.

Parameters
strings_zis NULL terminated list of afw_utf8_z_t pointers.
separatoror NULL for no separator.
pto use.
xctxof caller.
Returns
utf8_z 0 terminated string.

The input strings must already be valid utf-8. An error is thrown if it is not.

Definition at line 994 of file afw_utf8.c.

◆ afw_utf8_z_concat()

const afw_utf8_z_t* afw_utf8_z_concat ( const afw_pool_t p,
afw_xctx_t xctx,
  ... 
)

Concatenate zero terminated UTF8 strings in specifed pool.

◆ afw_utf8_z_create()

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.

Parameters
spointer to utf-8 characters.
lenis number of bytes.
ppool used for result.
xctxof caller.

A copy is always required to add a 0 byte.

An error is thrown if s is not valid utf-8.

Definition at line 366 of file afw_utf8.c.

◆ afw_utf8_z_equal()

afw_boolean_t afw_utf8_z_equal ( const afw_utf8_z_t s1,
const afw_utf8_z_t s2 
)
Todo:
FIXME: Need to fix comments below and polish comments above.

Compare two zero terminated UTF8 strings to be equal. Strings should already be normalized (NFC, etc.)

Definition at line 799 of file afw_utf8.h.

◆ afw_utf8_z_equal_ignore_case()

afw_boolean_t afw_utf8_z_equal_ignore_case ( const afw_utf8_z_t s1,
const afw_utf8_z_t s2 
)

Compare two zero terminated UTF8 strings to be equal. Strings should already be normalized (NFC, etc.)

Todo:
FIXME: FIXME This needs to change to be like afw_utf8_z_compare_ignore_case() when XACML is chanced not to use this. New version has xctx so error can be thrown if string is not UTF8 or too large.

Definition at line 817 of file afw_utf8.h.

◆ afw_utf8_z_file_name_from_path()

const afw_utf8_z_t* afw_utf8_z_file_name_from_path ( const afw_utf8_z_t path_z)

Returns pointer in path_z past last / or .

Definition at line 873 of file afw_utf8.h.

◆ afw_utf8_z_printf()

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,
  ... 
)

Create a utf8_z string using a c format string in specified pool.

Definition at line 854 of file afw_utf8.h.

◆ afw_utf8_z_printf_v()

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 
)

Create a utf8_z string using a c format string and va_list in specified pool.

Definition at line 844 of file afw_utf8.c.

◆ afw_utf8_z_query_string_to_object()

const afw_object_t* afw_utf8_z_query_string_to_object ( const afw_utf8_z_t s,
afw_xctx_t xctx 
)

Query string to object.

◆ afw_utf8_z_source_file()

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 '\'.

Parameters
source_z
Returns
pointer past last '/ 'or '\'.

This function is intended to return the pointer into a passed FILE that is past the last '/' or '\' for compilers that provide the full path.

Definition at line 1037 of file afw_utf8.c.

◆ afw_utf8_z_starts_with_z()

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.

Parameters
spointer to utf-8 characters.
s1_z0 terminated string.
s2_z0 terminated string.
Returns
true or false.

Definition at line 756 of file afw_utf8.h.