Home > Back-end >  Under the delphi2010 Stringlist support for ansiString is not complete
Under the delphi2010 Stringlist support for ansiString is not complete

Time:10-04

The original problem http://bbs.csdn.net/topics/330198862

Simplify it, this is the case, you look at the final tmpStr is # 0
Var
TmpStrList: TStringList;
TmpStr: AnsiString;
The begin
TmpStrList:=TStringList. Create;
TmpStrList. Add (a='test');
TmpStr:=ansiChar (168);//# $A8
tmpStrList. Values [' a '] :=tmpStr;
TmpStr:=tmpStrList) Values (' a ');//tmpStr they became # 0
end;

I couldn't resist, to dig the grave

To see a lot of post is not the point, couldn't help it.

The key on the red line

TmpStrList. Values [' a '] :=tmpStr;

Before the actual assignment through similar trim processing, 168 have been cut down

You can use the 'this' add whitespace characters in front of the test can see
Spaces were gone

Results: so not visible characters does not apply to tmpStrList Values: [' a ']=...

Delphi2010 test

CodePudding user response:

Post is not said has nothing to do with TStringList, before the set values, the ansistring unicodestring, where data is lost, you can be in TStrings. SetValue (const Name, Value, string) method, the observed Value Value, as zuobaoquan netizens described, unicodestring is not suitable for storage bytes,
  • Related