德尔福2009演员阵容长度为2

non*_*one 2 delphi string casting delphi-2009

看看如何抑制编译器发出的可能数据丢失的警告,

st:= copy(str,0,2);
Run Code Online (Sandbox Code Playgroud)

其中st是string [2],str有2个以上的字符.

并且复制被定义为从str返回一个新的字符串,它是0,2个位置的子集.

Cos*_*und 5

这将抑制警告,但要注意底层问题仍然存在:从Unicode转换为AnsiString可能导致数据丢失.

st := ShortString(Copy(str,1,2));
Run Code Online (Sandbox Code Playgroud)

并且不要忘记Delphi stings是基于1的,字符串中的第一个char是1,而不是0.