📄 subject_19583.htm
字号:
<p>
序号:19583 发表者:jackxu 发表日期:2002-10-29 22:32:46
<br>主题:如何判断两个字节是否是中文呢?
<br>内容:比如说一个字符串是<BR>@12你好吗?<BR>需要在“你“后面插入一个字符”j“,我应该怎么做呢?关键是源字符串是未知的。<BR>多谢!
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:flydrgon 回复日期:2002-10-30 09:34:08
<br>内容:你可以看看以前的帖子《如何按圆周方向输出字符串 》,那里能找到答案。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:jackxu 回复日期:2002-10-30 10:43:56
<br>内容:多谢,理解该怎么做了!谢谢!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:徐景周 回复日期:2002-10-30 10:50:48
<br>内容:可参看下面文章第12法:<BR>http://www.copathway.com/itbookreview/view_paper.asp?paper_id=363<BR><BR>如:<BR>//功能:根据新、老矩形,重新计算行数,使文字多行显示,jingzhou xu<BR> //---------------------------------------------------------------------------------------------<BR> //一行中最大字符数<BR> int nMaxLineChar = abs(lpRect->right - lpRect->left) / tmpWidth ; <BR> //记录当前行的宽度<BR> short theLineLength=0; <BR> //记录当前行中汉字字节数,以防止将一半汉字分为两行<BR> unsigned short halfChinese=0;<BR><BR> for(int i=0; i<=szString.GetLength()-1; i++)<BR> {<BR> if(((unsigned char)szString.GetAt(i) == 0x0d) && ((unsigned char)szString.GetAt(i+1) == 0x0a))<BR> theLineLength=0;<BR><BR> //大于0xa1的字节为汉字字节<BR> if((unsigned char)szString.GetAt(i) >= 0xA1)<BR> halfChinese++;<BR> theLineLength++;<BR><BR> //如果行宽大于每行最大宽度,进行特殊处理<BR> if(theLineLength > nMaxLineChar)<BR> {<BR> //防止将一个汉字分为两行,回溯<BR> if(halfChinese%2)<BR> {<BR> szString.Insert(i,(unsigned char)0x0a);<BR> szString.Insert(i,(unsigned char)0x0d);<BR> }<BR> else<BR> {<BR> szString.Insert(i-1,(unsigned char)0x0a);<BR> szString.Insert(i-1,(unsigned char)0x0d);<BR> }<BR> <BR> theLineLength = 0;<BR> }<BR> }<BR><BR> //重新计算矩形边界范围<BR>// int tmpLine = int(abs(szString.GetLength()*tmpWidth / abs(lpRect->right - lpRect->left)-0.5));<BR>// tmpLine += (szString.GetLength()*tmpWidth % abs(lpRect->right - lpRect->left))? 1 : 0;<BR>// if(tmpLine == 0)<BR>// tmpLine = 1;<BR> if(rcInner.bottom > lpRect->bottom)<BR> rcInner.bottom = lpRect->bottom;<BR> if(rcInner.top < lpRect->top)<BR> rcInner.top = lpRect->top;<BR><BR> //---------------------------------------------------------------------------------------------<BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -