moved attrcopy_utf8()

This commit is contained in:
Juho Hiltunen
2018-03-03 23:31:13 +02:00
parent 07a19b3208
commit a4eca79304
2 changed files with 22 additions and 21 deletions
-21
View File
@@ -807,27 +807,6 @@ static wchar_t *GetSsmlAttribute(wchar_t *pw, const char *name)
return NULL;
}
static int attrcopy_utf8(char *buf, const wchar_t *pw, int len)
{
// Convert attribute string into utf8, write to buf, and return its utf8 length
unsigned int c;
int ix = 0;
int n;
int prev_c = 0;
if (pw != NULL) {
while ((ix < (len-4)) && ((c = *pw++) != 0)) {
if ((c == '"') && (prev_c != '\\'))
break; // " indicates end of attribute, unless preceded by backstroke
n = utf8_out(c, &buf[ix]);
ix += n;
prev_c = c;
}
}
buf[ix] = 0;
return ix;
}
static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out)
{
int sign = 0;
+22
View File
@@ -48,6 +48,7 @@
int attrcmp(const wchar_t *string1, const char *string2);
int attrlookup(const wchar_t *string1, const MNEM_TAB *mtab);
int attrnumber(const wchar_t *pw, int default_value, int type);
int attrcopy_utf8(char *buf, const wchar_t *pw, int len);
int attrcmp(const wchar_t *string1, const char *string2)
{
@@ -91,3 +92,24 @@ int attrnumber(const wchar_t *pw, int default_value, int type)
return value;
}
int attrcopy_utf8(char *buf, const wchar_t *pw, int len)
{
// Convert attribute string into utf8, write to buf, and return its utf8 length
unsigned int c;
int ix = 0;
int n;
int prev_c = 0;
if (pw != NULL) {
while ((ix < (len-4)) && ((c = *pw++) != 0)) {
if ((c == '"') && (prev_c != '\\'))
break; // " indicates end of attribute, unless preceded by backstroke
n = utf8_out(c, &buf[ix]);
ix += n;
prev_c = c;
}
}
buf[ix] = 0;
return ix;
}