Ejemplo n.º 1
0
int
main (void)
{	utf8_test () ;
	wchar_test () ;

	return 0 ;
} /* main */
Ejemplo n.º 2
0
static uint32_t text_stream_getchar32(RealTimeTextSinkData *stream) {
	uint32_t c = text_stream_getchar(stream);
	int t = utf8_test(c);
	switch (t) {
		case 1:
			return c;
		case 2:
			c = (c & 0x1F) << 6;
			c += ((uint32_t) text_stream_getchar(stream) & 0x3F);
			return c;
		case 3:
			c = (c & 0x0F) << 12;
			c += (((uint32_t) text_stream_getchar(stream) & 0x3F) << 6);
			c += ((uint32_t) text_stream_getchar(stream) & 0x3F);
			return c;
		case 4:
			c = (c & 0x7) << 19;
			c += (((uint32_t) text_stream_getchar(stream) & 0x3F) << 12);
			c += (((uint32_t) text_stream_getchar(stream) & 0x3F) << 6);
			c += ((uint32_t) text_stream_getchar(stream) & 0x3F);
			return c;
		default:
			return 0;
	}
}
Ejemplo n.º 3
0
static bool_t is_utf8_buf_ok(const uint8_t* b, const size_t s) {
	int i, t;
	for (i = 0, t = 0; i < (int)s; i++, t--) {
		if (t == 0) {
			t = utf8_test(b[i]);
			if (t <= 0) {
				return FALSE;
			}
		} else {
			if (utf8_test(b[i]) != 0) {
				return FALSE;
			}
		}
	}
	if (t) {
		return FALSE;
	}
	return TRUE; /* SUCCESS */
}
Ejemplo n.º 4
0
static int
do_test (void)
{
  int result = 0;

  /* Check mapping of ASCII range for some character sets which have
     ASCII as a subset.  For those the wide char generated must have
     the same value.  */
  setlocale (LC_ALL, "C");
  result |= check_ascii (setlocale (LC_ALL, NULL));

  setlocale (LC_ALL, "de_DE.UTF-8");
  result |= check_ascii (setlocale (LC_ALL, NULL));
  result |= utf8_test ();

  setlocale (LC_ALL, "ja_JP.EUC-JP");
  result |= check_ascii (setlocale (LC_ALL, NULL));

  return result;
}