Example #1
0
/** 
 * return TRUE if the string s is a sequence of digits.
 */
static int is_number(const char *s)
{
	int nb;
	while(*s != '\0') {
		nb = is_utf8_digit(s);
		if (!nb) return FALSE;
		s += nb;
	}
	return TRUE;
}
Example #2
0
/**
 * The ":" is included here so we allow "10:30" to be a number.
 * We also allow U+00A0 "no-break space"
 */
static int is_number(const char * s)
{
	wchar_t c;
	if (!is_utf8_digit(s)) return FALSE;

	while (*s != 0)
	{
		int nb = mbtowc(&c, s, 4);
		if (iswdigit(c)) { s += nb; }

		/* U+00A0 no break space */
		else if (0xa0 == c) { s += nb; }

		else if ((*s == '.') || (*s == ',') || (*s == ':')) { s++; }
		else return FALSE;
	}
	return TRUE;
}