日语汉字判断

 

応用場合
 プログラムで漢字がある文字列を切れる。
    例えば、文字列改行/最後...にする
UnicodePageに日本語漢字の範囲で判断
BOOL ChkKanji(unsigned char c1,unsigned char c2) {
BOOL isknj1 = false;BOOL isknj2 = false;  //第1バイトチェック
if(((c1 >= 0x81) && (c1 <= 0x9F)) || ((c1 >= 0xED) && (c1 <= 0xFC))){
isknj1 = true;}
if(((c2 >= 0x40) && (c2 <= 0xFC) && (c2 != 0x7F))){isknj2 = true;}
if(isknj1 && isknj2)return TRUE;
return FALSE;
}
 
MS社のAPI IsDBCSLeadByte
Returns a nonzero value if the test character is potentially a lead byte.
The function returns 0 if the test character is not a lead byte or if it is a single-byte character.
 
応用場合
GDI で文字列を表示するCustomizeComponent作成する
Csize CDC::GetTextExtent
    Call this member function to compute the width and height of a line of text using the current font to determine the dimensions.
 
Etc1
CSize cs = dc->GetTextExtent(lpStr, (int)_tcslen(lpStr));
if (cs.cx > 220){
    dc->DrawText(lpStr, CRect(x, y, x+width, y+height), DT_LEFT | DT_NOPREFIX);
}else{
dc->DrawText(lpStr, CRect(x, y, x+width, y+height), DT_WORDBREAK| DT_CENTER | DT_NOPREFIX);
}
  DT_END_ELLIPSIS /  DT_PATH_ELLIPSIS /DT_NOPREFIX
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值