CnPack Forum


 
Subject: MicroTip#2:将中或英字符串转换为 Delphi 的 Dfm 格式
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 08:46  Profile | Blog | P.M.  | QQ
MicroTip#2:将中或英字符串转换为 Delphi 的 Dfm 格式

// MicroTip#2:将中或英字符串转换为 Delphi 的 Dfm 格式
// Test in Delphi6's Dfm
// Wrtten by SkyJacker 2007.03.05
// QQ Discuss Group: 130970

// 将中或英字符串转换为 Delphi 的 Dfm 格式
// Ex: 'CnPack Delphi '#20195#30721#24341#25806' V1.0' . Maybe you can reverse it!  
function StrToDfmFmt(const AStr: string): string;
const
  QM = '''';
var
  W: WideString;
  I: Integer;
  bEn: Boolean;
  Len: Integer;
begin
  bEn := False;
  W := AStr;
  Len := Length(W);
  for I:=1 to Len do
  begin
    if Ord(W)>127 then // 如果为非普通 ascii,就认为是宽字符
    begin
      if bEn then
        Result := Result + QM;

      Result := Result + '#' + IntToStr(Ord(W[I]));
      bEn := false;
    end
    else
    begin
      if not bEn then
        Result := Result + QM + W
      else
        Result := Result + W;

      if I = Len then
        Result := Result + QM;
      bEn := true;
    end;
  end;
end;




一壶清茶煮青春.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-3-12 09:25  Profile | Blog | P.M. 
if Ord(W)>127

这个用法还真新鲜。
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:42  Profile | Blog | P.M.  | QQ
阿.
我的原文是:
if Ord(W)>127 then // 如果为非普通 ascii,就认为是宽字符

我是先放在 UE 中再Copy的.
难道弄丢了.

上面的Ord(W)就不改了,当作一个小后门吧。




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:43  Profile | Blog | P.M.  | QQ
  Discuz 过滤了.

阿.
我的原文是:
if Ord(W { i })>127 then // 如果为非普通 ascii,就认为是宽字符




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:44  Profile | Blog | P.M.  | QQ
W[I]




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:44  Profile | Blog | P.M.  | QQ
(W[I])




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:44  Profile | Blog | P.M.  | QQ
Ord(W[I])




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:45  Profile | Blog | P.M.  | QQ
Ord(W[I]) >




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:45  Profile | Blog | P.M.  | QQ
if Ord(W)>127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:46  Profile | Blog | P.M.  | QQ
Ord(W)>127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:46  Profile | Blog | P.M.  | QQ
(W)>127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 09:49  Profile | Blog | P.M.  | QQ
总结:
Discuz! 5.0.0 会过滤类似于以下字符串:
(W{I})>127

"{}" 实际为 "[]"

Thx Passion!




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 10:04  Profile | Blog | P.M.  | QQ
让此帖作为我的灌水测试帖吧

小于
(W[I]) < 127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 10:05  Profile | Blog | P.M.  | QQ
(W[I]) and (W[I]) > 127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 10:05  Profile | Blog | P.M.  | QQ
((W[I]) and (W[I])) > 127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 10:06  Profile | Blog | P.M.  | QQ
((W[I]) && (W[I])) > 127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 10:06  Profile | Blog | P.M.  | QQ
W[ I ] > 127




一壶清茶煮青春.
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2007-3-12 10:07  Profile | Blog | P.M.  | QQ
(W[ I ])>127




一壶清茶煮青春.
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-3-12 11:57  Profile | Blog | P.M. 
明白了, 得禁用DISCUZ! 代码,否则那个方括号I就被当成斜体了。
Top
kendling (小冬)
高级版主
Rank: 8Rank: 8
MyvNet


Medal No.1  
UID 703
Digest Posts 5
Credits 978
Posts 580
点点分 978
Reading Access 101
Registered 2005-2-18
Location 广东
Status Offline
Post at 2007-3-14 10:00  Profile | Site | Blog | P.M.  | QQ | Yahoo!
怪不得看起来怪怪的。




小冬
http://MyvNet.com
Top
 




All times are GMT++8, the time now is 2024-11-22 13:22

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.010287 second(s), 9 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP