L[telnet negotiation] 这层处理汉字问题
|
L[event driven state machine] 这层就不用分析字符编码了
实现:
class Char {
public:
bool ascii;
char ch0, ch1;
Char();
Char(char);
Char(char, char);
int size();
int length(); // 2 or 1
char* c_str();
};
定义字符,
定义事件:
class Event {
public:
int type;
Char key;
Event() : type(EV_NOP){};
Event(int t) : type(t){};
Event(int t, Char k) : type(t), key(k){};
};
demo:
if (event.type == EV_INPUT) {
if (event.key.ascii) {
}
else {
}
}
--
FROM 61.235.136.251