急急急,如何判断 一行中的某个位置,是一个字的上半字符,还是下半字符?sos
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




