mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-01 21:58:52 +00:00
encoding.c: Create a text_decoder_decode_string_multibyte helper to work with the espeakCHARS_* flags.
This commit is contained in:
@@ -731,6 +731,29 @@ text_decoder_decode_wstring(espeak_ng_TEXT_DECODER *decoder,
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
espeak_ng_STATUS
|
||||
text_decoder_decode_string_multibyte(espeak_ng_TEXT_DECODER *decoder,
|
||||
const void *input,
|
||||
espeak_ng_ENCODING encoding,
|
||||
int flags)
|
||||
{
|
||||
switch (flags & 7)
|
||||
{
|
||||
case espeakCHARS_WCHAR:
|
||||
return text_decoder_decode_wstring(decoder, (const wchar_t *)input, -1);
|
||||
case espeakCHARS_AUTO:
|
||||
return text_decoder_decode_string_auto(decoder, (const char *)input, -1, encoding);
|
||||
case espeakCHARS_UTF8:
|
||||
return text_decoder_decode_string(decoder, (const char *)input, -1, ESPEAKNG_ENCODING_UTF_8);
|
||||
case espeakCHARS_8BIT:
|
||||
return text_decoder_decode_string(decoder, (const char *)input, -1, encoding);
|
||||
case espeakCHARS_16BIT:
|
||||
return text_decoder_decode_string(decoder, (const char *)input, -1, ESPEAKNG_ENCODING_ISO_10646_UCS_2);
|
||||
default:
|
||||
return ENS_UNKNOWN_TEXT_ENCODING;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
text_decoder_eof(espeak_ng_TEXT_DECODER *decoder)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,12 @@ text_decoder_decode_wstring(espeak_ng_TEXT_DECODER *decoder,
|
||||
const wchar_t *string,
|
||||
int length);
|
||||
|
||||
espeak_ng_STATUS
|
||||
text_decoder_decode_string_multibyte(espeak_ng_TEXT_DECODER *decoder,
|
||||
const void *input,
|
||||
espeak_ng_ENCODING encoding,
|
||||
int flags);
|
||||
|
||||
int
|
||||
text_decoder_eof(espeak_ng_TEXT_DECODER *decoder);
|
||||
|
||||
|
||||
@@ -1970,26 +1970,8 @@ const void *TranslateClause(Translator *tr, const void *vp_input, int *tone_out,
|
||||
if (p_decoder == NULL)
|
||||
p_decoder = create_text_decoder();
|
||||
|
||||
switch (option_multibyte)
|
||||
{
|
||||
case espeakCHARS_WCHAR:
|
||||
text_decoder_decode_wstring(p_decoder, (const wchar_t *)vp_input, -1);
|
||||
break;
|
||||
case espeakCHARS_AUTO:
|
||||
text_decoder_decode_string_auto(p_decoder, (const char *)vp_input, -1, tr->encoding);
|
||||
break;
|
||||
case espeakCHARS_UTF8:
|
||||
text_decoder_decode_string(p_decoder, (const char *)vp_input, -1, ESPEAKNG_ENCODING_UTF_8);
|
||||
break;
|
||||
case espeakCHARS_8BIT:
|
||||
text_decoder_decode_string(p_decoder, (const char *)vp_input, -1, tr->encoding);
|
||||
break;
|
||||
case espeakCHARS_16BIT:
|
||||
text_decoder_decode_string(p_decoder, (const char *)vp_input, -1, ESPEAKNG_ENCODING_ISO_10646_UCS_2);
|
||||
break;
|
||||
default:
|
||||
return NULL; // unknown multibyte option value
|
||||
}
|
||||
if (text_decoder_decode_string_multibyte(p_decoder, vp_input, tr->encoding, option_multibyte) != ENS_OK)
|
||||
return NULL;
|
||||
|
||||
embedded_ix = 0;
|
||||
embedded_read = 0;
|
||||
|
||||
Reference in New Issue
Block a user