36 "k_lfn_utf8_cap must hold the longest VFAT long name in UTF-8");
39 "k_exfat_name_u8_cap must hold the longest exFAT name in UTF-8");
74 const uint32_t u = (uint32_t)b;
127 for (uint32_t k = 1U; k < len; k++) {
128 const uint32_t b = (uint32_t)(
unsigned char)in[lead + k];
216 const uint32_t pos = *io_pos;
261 const uint32_t n = *io_n;
268 if ((n + need) > cap) {
272 out[n] = (uint16_t)cp;
285 if ((in ==
nullptr) || (out ==
nullptr) || (out_units ==
nullptr)) {
294 if (in[pos] ==
'\0') {
349 const uint32_t i = *io_i;
350 const uint32_t hi = (uint32_t)in[i];
359 if ((i + 1U) >= units) {
362 const uint32_t lo = (uint32_t)in[i + 1U];
438 for (uint32_t k = len - 1U; k >= 1U; k--) {
440 out[from + k] = (char)(
unsigned char)b;
473 const uint32_t n = *io_n;
475 if ((n + len + 1U) > cap) {
479 out[n] = (char)(
unsigned char)cp;
492 out[n] = (char)(
unsigned char)(lead_tag | lead_bits);
501 if ((in ==
nullptr) || (out ==
nullptr) || (cap == 0U)) {
529uint8_t
priv_utf16_ieq(
const uint16_t* a, uint32_t an,
const uint16_t* b, uint32_t bn)
534 for (uint32_t i = 0U; i < an; i++) {
545 for (uint32_t i = 0U; i < units; i++) {
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
uint16_t priv_exfat_upcase_unit(uint16_t unit)
Fold a UTF-16 code unit through the canonical exFAT up-case table.
Cross-TU shared declarations for the FAT/exFAT ra8_fs adapter.
@ k_exfat_name_u8_cap
That name in UTF-8: 3 * 64, plus a NUL.
@ k_exfat_name_cap
Longest name we store, in UTF-16 units.
@ k_lfn_utf8_cap
A 247-unit name in UTF-8: 3 * 247, + NUL.
@ k_lfn_write_max
Longest name we WRITE (k_lfn_max_entries).
uint8_t priv_utf16_ieq(const uint16_t *a, uint32_t an, const uint16_t *b, uint32_t bn)
Compare two UTF-16 names for case-insensitive equality.
uint8_t priv_utf16_all_ascii(const uint16_t *in, uint32_t units)
Is every unit of in inside the ASCII range?
ra8_err_t priv_utf8_to_utf16(const char *in, uint16_t *out, uint32_t cap, uint32_t *out_units)
Convert a NUL-terminated UTF-8 name into UTF-16LE code units.
static ra8_err_t internal_utf8_put(uint32_t cp, char *out, uint32_t cap, uint32_t *io_n)
Append cp to a UTF-8 buffer, reserving room for the terminator.
static ra8_err_t internal_utf8_next(const char *in, uint32_t *io_pos, uint32_t *out_cp)
Decode the sequence at *io_pos, advancing the cursor past it.
static void internal_utf8_put_tail(char *out, uint32_t from, uint32_t len, uint32_t cp)
Write the continuation bytes of cp after its lead byte.
static uint8_t internal_utf8_tail(const char *in, uint32_t lead, uint32_t len, uint32_t *io_cp)
Fold a sequence's continuation bytes into the code point under assembly.
static uint8_t internal_utf8_wellformed(uint32_t cp, uint32_t len)
Is cp a code point that a len byte sequence may legally encode?
static uint8_t internal_utf8_lead(uint8_t b, uint32_t *out_len, uint32_t *out_cp)
Classify a UTF-8 lead byte into a sequence length and its payload bits.
static ra8_err_t internal_utf16_take(const uint16_t *in, uint32_t units, uint32_t *io_i, uint32_t *out_cp)
Take the character at *io_i, consuming a surrogate pair as one.
static uint32_t internal_utf8_len_of(uint32_t cp)
How many UTF-8 bytes does cp occupy?
ra8_err_t priv_utf16_to_utf8(const uint16_t *in, uint32_t units, char *out, uint32_t cap)
Convert UTF-16LE code units into a NUL-terminated UTF-8 name.
static ra8_err_t internal_utf16_put(uint32_t cp, uint16_t *out, uint32_t cap, uint32_t *io_n)
Append cp to a UTF-16 buffer as one unit or as a surrogate pair.
UTF-8 <-> UTF-16LE conversion and case folding for ra8_fs names.
@ k_utf_min_4byte
Smallest code point a 4-byte form may hold.
@ k_utf_lead3_tag
Tag of a three-byte lead byte.
@ k_utf_cont_shift
Payload width of one continuation byte.
@ k_utf_sur_shift
Payload width of one surrogate unit.
@ k_utf_code_max
Largest code point Unicode defines.
@ k_utf_len_1
Sequence length: plain ASCII.
@ k_utf_lead3_mask
Mask isolating a three-byte lead's tag.
@ k_utf_len_3
Sequence length: three bytes.
@ k_utf_sur_hi_first
First high (leading) surrogate unit.
@ k_utf_lead4_payload
Payload bits in a four-byte lead.
@ k_utf_lead2_payload
Payload bits in a two-byte lead.
@ k_utf_cont_tag
Tag every continuation byte carries.
@ k_utf_len_2
Sequence length: two bytes.
@ k_utf_lead4_tag
Tag of a four-byte lead byte.
@ k_utf_min_2byte
Smallest code point a 2-byte form may hold.
@ k_utf_lead4_mask
Mask isolating a four-byte lead's tag.
@ k_utf_sur_mask
Payload bits in one surrogate unit.
@ k_utf_cont_payload
Payload bits in a continuation byte.
@ k_utf_sur_lo_first
First low (trailing) surrogate unit.
@ k_utf_lead2_mask
Mask isolating a two-byte lead's tag.
@ k_utf_lead3_payload
Payload bits in a three-byte lead.
@ k_utf_ascii_max
Highest code point that is one UTF-8 byte.
@ k_utf_lead2_tag
Tag of a two-byte lead byte.
@ k_utf_sur_last
Last surrogate unit of either half.
@ k_utf_len_4
Sequence length: four bytes.
@ k_utf_cont_mask
Mask isolating a continuation byte's tag.
@ k_utf_min_3byte
Smallest code point a 3-byte form may hold.
@ k_utf8_max_per_unit
Worst-case UTF-8 bytes per UTF-16 unit.