SDL_FlushIMString -- Get IM string content.
SDL_FlushIMString -- IMの変換済みの文字列を取得する。
#include “SDL.h”
int SDL_FlushIMString(void *buffer);
Get IM string content (UNICODE or local code string).
The argument "buffer"'s type is depended on enabling UNICODE or not by function "SDL_EnableUNICODE()".
If setting SDL_EnableUNICODE(1) or SDL_EnableUNICODE(-1) returns 1(or true), the argument buffer is the Uint16-type UCS2 string.
If setting SDL_EnableUNICODE(0) or SDL_EnableUNICODE(-1) returns 0(or false), the argument buffer is the char-type local string(MBCS, multi-byte characters set) depends on the local environment, either DBCS(double-byte characters set) or UTF-8.
If the argument is not NULL, it will flush string from inner buffer to outer buffer specified in argument(it follows X-style.).
Return string length.
IM の変換済み文字列を取得します。 (UNICODE か local code string).
buffer 引数に格納される文字列のタイプは、SDL_EnableUNICODE()関数により、UNICODEかそうでないかが指定されます。
も し、SDL_EnableUNICODE(1) か SDL_EnableUNICODE(-1) が 1(か真)を返したなら、buffer引数には、Uint16型でUCS2の文字列が格納されます。
も し、SDL_EnableUNICODE(0) か SDL_EnableUNICODE(-1)が 0(か偽)を返したなら、buffer引数には、char型の環境に依存した、local code 文字列(MBCS, マルチバイトキャラクターセット)が格納されます。DBCS(double-type キャラクターセット)かUTF-8が使用されます。
も し、buffer引数がNULLでなかった場合、buffer引数指定されたバッファに変換済み文字列が格納されます。(Xのスタイルに従って)
文 字列の長さを返します。
注 意:返された長さは、終端文字を含まない文字列の長さになります。また、bufferに格納する文字列はNULL終端されません。
SDL_Event event; /* Event structure */
Uint16 *buf;
int len;
buf = 0;
.
.
.
/* Enable UNICODE */
SDL_EnableUNICODE(1);
/* Check for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
if (len = SDL_FlushIMString(NULL)) { /* Get the string length */
buf = (Uint16*)malloc( (len+1) * sizeof(Uint16) );
SDL_FlushIMString(buf); /* Get the string content */
buf[len] = '\0';
}
if (buf) {
free(buf);
buf = 0;
}
break;
}
}