esp32-audio-player 0.1.0
Audio player engine for ESP32
Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
4#pragma once
5
6#include "audio_player/base.h"
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
20
23size_t text_to_utf8(const uint8_t *in, size_t len, text_encoding_t enc, char *out, size_t out_size);
24
27text_encoding_t text_detect_legacy(const uint8_t *in, size_t len);
28
29bool text_is_valid_utf8(const uint8_t *in, size_t len);
30
32size_t utf8_decode(const char *s, uint32_t *cp);
33size_t utf8_encode(uint32_t cp, char out[4]);
34size_t utf8_strlen(const char *s);
36void utf8_truncate(char *s, size_t max_bytes);
37void text_trim(char *s);
38
39#ifdef __cplusplus
40}
41#endif
Base definitions shared by every core module: error codes, memory, logging, locks.
size_t utf8_encode(uint32_t cp, char out[4])
void utf8_truncate(char *s, size_t max_bytes)
Truncate to at most max_bytes without splitting a code point.
size_t utf8_decode(const char *s, uint32_t *cp)
Decode one code point; returns bytes consumed (>=1) and stores cp (U+FFFD on error).
void text_trim(char *s)
trims ASCII whitespace in place
size_t text_to_utf8(const uint8_t *in, size_t len, text_encoding_t enc, char *out, size_t out_size)
Convert to UTF-8.
size_t utf8_strlen(const char *s)
code points
text_encoding_t
Definition text.h:12
@ TEXT_ENC_UTF16BE
ID3 encoding 2.
Definition text.h:15
@ TEXT_ENC_UTF8
ID3 encoding 3.
Definition text.h:16
@ TEXT_ENC_AUTO_LEGACY
single-byte text of unknown code page: detect UTF-8 / CP1251 / Latin-1
Definition text.h:18
@ TEXT_ENC_LATIN1
Definition text.h:13
@ TEXT_ENC_CP1251
Definition text.h:17
@ TEXT_ENC_UTF16_BOM
ID3 encoding 1.
Definition text.h:14
bool text_is_valid_utf8(const uint8_t *in, size_t len)
text_encoding_t text_detect_legacy(const uint8_t *in, size_t len)
Heuristic for 8-bit legacy text: valid UTF-8 -> UTF8; mostly bytes 0xC0..0xFF forming Russian words -...