Browse Source

moved attrcopy_utf8()

master
Juho Hiltunen 7 years ago
parent
commit
a4eca79304
2 changed files with 22 additions and 21 deletions
  1. 0
    21
      src/libespeak-ng/readclause.c
  2. 22
    0
      src/libespeak-ng/ssml.c

+ 0
- 21
src/libespeak-ng/readclause.c 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
- 0
src/libespeak-ng/ssml.c 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;
}


Loading…
Cancel
Save