mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-05 14:47:26 +00:00
encoding.c: Support using wchar_t strings with the text decoder API.
This commit is contained in:
@@ -581,6 +581,14 @@ string_decoder_getc_iso_10646_ucs_2(espeak_ng_TEXT_DECODER *decoder)
|
||||
return c1 + (c2 << 8);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
string_decoder_getc_wchar(espeak_ng_TEXT_DECODER *decoder)
|
||||
{
|
||||
wchar_t c = *(const wchar_t *)decoder->current;
|
||||
decoder->current += sizeof(wchar_t);
|
||||
return c;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t (*get)(espeak_ng_TEXT_DECODER *decoder);
|
||||
@@ -651,6 +659,18 @@ text_decoder_decode_string(espeak_ng_TEXT_DECODER *decoder,
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
espeak_ng_STATUS
|
||||
text_decoder_decode_wstring(espeak_ng_TEXT_DECODER *decoder,
|
||||
const wchar_t *string,
|
||||
int length)
|
||||
{
|
||||
decoder->get = string_decoder_getc_wchar;
|
||||
decoder->codepage = NULL;
|
||||
decoder->current = (const uint8_t *)string;
|
||||
decoder->end = (const uint8_t *)(string + length);
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
text_decoder_eof(espeak_ng_TEXT_DECODER *decoder)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,11 @@ text_decoder_decode_string(espeak_ng_TEXT_DECODER *decoder,
|
||||
int length,
|
||||
espeak_ng_ENCODING encoding);
|
||||
|
||||
espeak_ng_STATUS
|
||||
text_decoder_decode_wstring(espeak_ng_TEXT_DECODER *decoder,
|
||||
const wchar_t *string,
|
||||
int length);
|
||||
|
||||
int
|
||||
text_decoder_eof(espeak_ng_TEXT_DECODER *decoder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user