/// <summary> /// 处理TextInput事件 /// </summary> private static unsafe void HandleTextInputEvent(SDL_TextInputEvent e) { uint byteCount = 0; // Loop until the null terminator is found or the max size is reached. while (byteCount < SDL_TextInputEvent.MaxTextSize && e.text[byteCount++] != 0) { } if (byteCount > 1) { // We don't want the null terminator. byteCount -= 1; int charCount = Encoding.UTF8.GetCharCount(e.text, (int)byteCount); char * charsPtr = stackalloc char[charCount]; var syt = Encoding.UTF8.GetString(e.text, (int)byteCount); string input_text = syt; CefRange range = new CefRange(); range.From = -1; _host.ImeCommitText(input_text, range, 0); } }