Exemplo n.º 1
0
static void convert_utf16_to_utf8_len(std::wstring s, int &len)
{
	if (len >= 0 && len <= s.size())
		len = count_utf_8_from_16(s.substr(0, len).c_str()) - 1;
	else
		len = -1;
}
Exemplo n.º 2
0
static char *BLI_alloc_utf_8_from_16(wchar_t *in16, size_t add)
{
	size_t bsize = count_utf_8_from_16(in16);
	char *out8 = NULL;
	if (!bsize) return NULL;
	out8 = (char *)MEM_mallocN(sizeof(char) * (bsize + add), "UTF-8 String");
	conv_utf_16_to_8(in16, out8, bsize);
	return out8;
}
Exemplo n.º 3
0
static size_t updateUtf8Buf(ImeComposition &info)
{
	size_t len = count_utf_8_from_16(info.ime_string.c_str());
	info.utf8_buf.resize(len);
	conv_utf_16_to_8(info.ime_string.c_str(), &info.utf8_buf[0], len);
	convert_utf16_to_utf8_len(info.ime_string, info.cursor_position);
	convert_utf16_to_utf8_len(info.ime_string, info.target_start);
	convert_utf16_to_utf8_len(info.ime_string, info.target_end);
	return len - 1;
}