s1结果?why? (300分)

影 子

Unregistered / Unconfirmed
GUEST, unregistred user!
var
s1,s2,s3 : WideString;//Ansistring
begin
s2:='';
s3:='';
s1:='Hello';
s1:=s2+s3;
ShowMessage(s1);

end;

附:
新浪的控股方竟是日本,怪不得日本人在西大买春的丑闻新浪网充耳不闻,打灯笼都找不到!许多网友发誓:新浪不更名,永不登录新浪!!
  刚从日本回来的华侨林小姐说:“在日语罗马字里,(sina)就是(支那),是部分日本人对中国带有侮辱性的称呼。这个词,主要是右翼分子在使用。”林小姐说:“在日本的中国人,只要一听到sina这个词,就觉得受到莫大的侮辱。这样一个有歧视性的字眼,怎么可以用做中国人自己的网站的名字呢?” 林小姐的家人听后更是感到惊异,因为他们常用新浪免费电子邮箱与日本朋友和客户联系,对方看到中国人自己用“支那”邮箱发信,会不会觉得中国人自己承认是“支那人”呢?
 北京大学外国语学院日语系教授刘金才查阅了权威典籍,证实“sina”与日文中“支那”的发音完全相同。北京外国语大学、社科院的语言学家和史学家们也证实:“sina”就是“支那”。
 
黑了他们!
si结果“ ”无
 
一听到日本这些狗东西的事情就来气。
 
抵制日货!
s1=''
 
var
s1,s2,s3 : WideString;//Ansistring
begin
s2:='';
s3:='';
s1:='Hello';
s1:=s2+s3;
ShowMessage(s1);
//这里应该访问了已经不属于s1的内存了
end;
结果s1='Hello'
WideString不知道怎么处理的..它有没有引用计数?有没有末尾补#0?
var
s1,s2,s3 : WideString;//Ansistring
begin
s2:=''+#0;
s3:=''+#0;
s1:='Hello';
s1:=s2+s3;
ShowMessage(s1);
end;
 
我来听课
WideString没有引用计数;不知道后面有没有补#0
var
s1,s2,s3 : WideString;//Ansistring
begin
s2:='';
s3:='';
s1:='Hello';
s1:=s2;
//+s3;
改一下,又可以了;问题是不是出在这一步?
ShowMessage(s1);

end;
 
s1:='Hello';执行后S1内存地址的内容应该是“Hello ”共六个字节
s1:=s2+s3;执行后就是两个“ ”相加,自动合并后成为一个“ ”,但你显示的时候会把这个东西自动去掉,就只能是空了,对同一个变量赋值只能是最后一个成功,前边的都会自动冲掉数据。如果S1是一个PCHAR数组,还能把东西读出来一部分。
 
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
新浪不更名,永不登录新浪!!
 
结果是hello
The WideChar type allows wide character strings to be represented as arrays of WideChars. Wide strings are strings composed of 16-bit Unicode characters. As with long strings, wide strings are dynamically allocated with a maximum length of two Gigabytes, but the practical limit is usually dependent on the amount of available memory. In Delphi, wide strings are not reference-counted. Every assignment of a wide string to a wide string var creates a copy of the string data. In Kylix, WideStrings are reference counted.
The dynamically allocated memory that contains the string is deallocated when the wide string goes out of scope. In all other respects wide strings possess the same attributes as long strings. The WideString type is denoted by the predefined identifier WideString.
Since the 32-bit version of OLE (Windows only) uses Unicode for all strings, strings must be of wide string type in any OLE automated properties and method parameters. Also, most OLE API functions use null-terminated wide strings.
 
光说是没有用的,
要搞一点有影响的行动哦,
每次上网都扔个炸弹玩玩,
呵呵~~~~~~~~~~~~~~~~~~~~~~~~~
 
这个影子是不是tencent上的影子啊,彼影是彼影还是彼影非彼影?
 
。。。。鬱悶。說來也怪。如果日本人叫"爸爸"也是侮辱中國人的話。那我們不要。。。。。。
不過小日本也太叼。
 
widestring 在 Delphi 内部被考虑为 pwidechar 。适用长字符串指针规则。这个规则的其
中一条是:
cast a long-string variable to a pointer, the pointer remains valid until the
variable is assigned a new value or goes out of scope.
 
这个题目很怪,按照程序的意思,
结果应该等于 "" 空字符串
但实际上不是,结果是 Hello
楼上的朋友说了那么多,还引经据典的,
可是没有人能说明白到底是怎么回事
通过跟踪生成的汇编代码,发现它是这样运行的
内部编译函数 WStrCat3
分别获得后面两个字符串的长度
如果第二个字符串长度为0
则判断第一个字符串的长度,
如果也为0,那么函数就直接返回了,什么也没有做,
也就是说,如果s2,s3长度都为0,
s1 := s2 + s3;
相当于什么操作都没有执行
而其它的情况都能正常执行!
所以, s1中当然还是 Hello
我相信这是Delphi中的一个Bug,因为WideString用的比较少,
主要是执行速度没有AnsiString快,
(对于大量的字符串操作,如果考虑性能的话,最好是用AnsiString)
所以,这个Bug一直没有被发现
 
这应该是个Bug
 
我从不用新浪,也不去,哈哈
 
ATACK。。。。。。。。。
 
新发现啊!
打倒小日本
 
试了下,结果是hello
 

Similar threads

回复
0
查看
864
不得闲
D
回复
0
查看
735
DelphiTeacher的专栏
D
D
回复
0
查看
711
DelphiTeacher的专栏
D
D
回复
0
查看
681
DelphiTeacher的专栏
D
顶部