CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  语言基础/算法/系统设计

急急急,如何判断 一行中的某个位置,是一个字的上半字符,还是下半字符?sos

楼主hameizi(梅子)2004-11-04 16:56:43 在 Delphi / 语言基础/算法/系统设计 提问

ji 问题点数:100、回复次数:9Top

1 楼warmworm(warmworm)回复于 2004-11-04 17:00:26 得分 0

在什么地方判断Top

2 楼beyondtkl(大龙驹<*好久没来了,兄弟们好吧。*>)回复于 2004-11-04 17:01:15 得分 10

好像   汉字   有专门的   区间的。。。这个相当于字典。。。  
  你先去了解一下   汉字的存储规则。。  
   
  偶也顺便看看Top

3 楼jinjazz(近身剪)回复于 2004-11-04 17:09:04 得分 10

procedure   TForm1.Button1Click(Sender:   TObject);  
  var   s:string;  
          i,m:integer;  
  begin  
      s:='中国de山大324市';     //字符  
      m:=10;                                   //第几个位置  
      if   ord(s[m])<128   then   showmessage('<128')  
      else  
      begin  
          for   i:=m   downto   0   do  
          if   (i>0)and(ord(s[i])<128)   then   break;  
          if   (m-i)   mod   2=1   then   showmessage('上')   else   showmessage('下')  
      end;  
  end;Top

4 楼jinjazz(近身剪)回复于 2004-11-04 17:10:18 得分 0

就是判断它是连续汉字字符串的第几个了,如果是奇数就是前半部分,偶数就是后半部分Top

5 楼beyondtkl(大龙驹<*好久没来了,兄弟们好吧。*>)回复于 2004-11-04 17:20:34 得分 0

晕   我理解错了。。。还以为   随便一个位置判断是某个汉字<字母>   的前半部分   还是   后半部分。。  
  Top

6 楼aiirii(ari-http://spaces.msn.com/members/aiirii/)回复于 2004-11-04 17:22:29 得分 30

用這個也可:  
   
  function   ByteType(const   S:   string;   Index:   Integer):   TMbcsByteType;  
   
   
  if   ByteType(aWord,   Length(aWord))   =   mbTrailByte   thenTop

7 楼jinjazz(近身剪)回复于 2004-11-04 17:25:41 得分 20

~~~郁闷,费了半天劲  
   
  Indicates   whether   a   byte   in   a   string   is   a   single   byte   character,   the   first   byte   of   a   double   byte   character,   or   the   second   byte   of   a   double   byte   character.Top

8 楼hameizi(梅子)回复于 2004-11-04 17:55:16 得分 0

随便一个位置判断是某个汉字<字母>   的前半部分   还是   后半部分。。  
   
   
  我问的就是这个呀!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Top

9 楼jorge(失恋狂牛仔)回复于 2004-11-05 00:52:32 得分 30

Indicates   whether   a   byte   in   a   string   is   a   single   byte   character,   the   first   byte   of   a   double   byte   character,   or   the   second   byte   of   a   double   byte   character.  
   
  Unit  
   
  SysUtils  
   
  Category  
   
  MBCS   utilities  
   
  Delphi   syntax:  
   
  function   ByteType(const   S:   string;   Index:   Integer):   TMbcsByteType;  
   
  C++   syntax:  
   
  extern   PACKAGE   TMbcsByteType   __fastcall   ByteType(const   AnsiString   S,   int   Index);  
   
  Description  
   
  Call   ByteType   to   determine   whether   a   specified   byte   in   a   string   is   a   single-byte   character,   the   first   byte   of   a   multibyte   character,   or   one   of   the   trailing   bytes.  
   
  AnsiString   is   the   string   that   contains   the   byte   in   question.  
   
  Index   identifies   the   byte   for   which   you   want   to   know   the   byte   type.   Bytes   are   numbered   from   1.  
   
  If   the   system   is   not   using   a   multi-byte   character   system   (MBCS),   ByteType   always   returns   mbSingleByte.   Otherwise,   ByteType   returns   mbSingleByte   if   the   indicated   byte   represents   a   complete   character   in   S,   mbLeadByte   if   it   represents   the   first   byte   of   a   double   byte   character,   and   mbTrailByte   if   it   represents   a   subsequent   byte   of   a   multibyte   character.  
   
  Note: No   checking   is   done   to   ensure   that   Index   is   less   than   the   length   of   S.   It   is   the   caller's   responsibility   to   ensure   that   Index   is   not   out   of   bounds.  
   
  =========================================================================================  
   
  TMbcsByteType   represents   the   use   of   a   single   byte   in   a   string   that   uses   a   multi-byte   character   set   (MBCS).  
   
  Unit  
   
  SysUtils  
   
  Delphi   syntax:  
   
  type   TMbcsByteType   =   (mbSingleByte,   mbLeadByte,   mbTrailByte);  
   
  C++   syntax:  
   
  enum   TMbcsByteType   {   mbSingleByte,   mbLeadByte,   mbTrailByte   };  
   
  Description  
   
  TMbcsByteType   represents   the   possible   return   values   of   the   ByteType   and   StrByteType   functions.     Possible   values   are   as   follows:  
   
  Values Meaning  
   
  mbSingleByte The   char   is   used   to   represent   an   entire   character   in   the   string.   The   value   of   Char   can   not   be   included   in   the   LeadBytes   set.  
  mbLeadByte The   char   is   used   to   represent   the   first   byte   of   a   multi-byte   character.     The   value   of   Char   must   be   included   in   the   LeadBytes   set.  
  mbTrailByte The   char   is   used   to   represent   one   of   the   trailing   bytes   in   a   multi-byte   character.   There   are   no   a   priori   restrictions   on   the   value   of   char.Top

相关问题

  • 判断字符?
  • 下班给分啊,请问大家怎么判断一个字符串,急急
  • 急急急!!!字符操作
  • 求助,关于如何判断字符串大小,谢谢,急,急,急,马上给分
  • 字符串判断
  • 急急急急急急急急急急急,求一取字符串的思路,急急急急急急急急
  • 急急急急急急急急急急急急急急,VB字符串查找菜鸟一问,急急急急急急急急急急急急急急
  • 在datagrid 控件,如何判断一行记录被选择中,急急...
  • 判断字符里的字符!
  • VB 字符串替换一问,急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急急

关键词

  • c++
  • 字符
  • 汉字
  • bytetype
  • tmbcsbytetype
  • mbsinglebyte
  • character
  • mbtrailbyte
  • mbleadbyte
  • byte

得分解答快速导航

  • 帖主:hameizi
  • beyondtkl
  • jinjazz
  • aiirii
  • jinjazz
  • jorge

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo