Beispiel #1
0
/**
 * @internal assumes that the input has already been validated by walkUTF8String
 */
static void
translateUTF8String (const U_8 * in, U_8 * out, IDATA nbytes)
{
  const U_8 *end = in + nbytes;
  const U_8 *cursor = in;
  /* walk the string again, translating it */
  while (cursor < end)
    {
      U_32 numberU8Consumed;
      if ((*cursor & 0x80) == 0x80)
        {
          U_16 unicode;
          int wcresult;
          numberU8Consumed = decodeUTF8Char (cursor, &unicode);
          cursor += numberU8Consumed;
          wcresult = wctomb (out, (wchar_t) unicode);
          if (wcresult == -1)
            {
              *out++ = '?';
            }
          else
            {
              out += wcresult;
            }
        }
      else
        {
          *out++ = *cursor++;
        }
    }
}
Beispiel #2
0
/**
 * @internal assumes that the input has already been validated by walkUTF8String
 */
static void
translateUTF8String(const uint8_t *in, uint8_t *out, intptr_t nbytes)
{
	const uint8_t *cursor = in;
	const uint8_t *const end = cursor + nbytes;

	/* walk the string again, translating it */
	while (cursor < end) {
		if ((*cursor & 0x80) == 0x80) {
			uint16_t unicode = 0;
			int wcresult = 0;
			uint32_t numberU8Consumed = decodeUTF8Char(cursor, &unicode);
			cursor += numberU8Consumed;
			wcresult = wctomb((char *)out, (wchar_t)unicode);
			if (wcresult == -1) {
				*out++ = '?';
			} else {
				out += wcresult;
			}
		} else {
			*out++ = *cursor++;
		}
	}
}