View Issue Details

IDProjectCategoryView StatusLast Update
0002345JEDI VCL00 JVCL Componentspublic2004-11-28 12:53
ReporteranonymousAssigned Touser72 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 BETA 2 
Target VersionFixed in Version3.00 RC 1 
Summary0002345: TJvSimpleXML encoded properites
DescriptionSaveToString has sideeffect of decoding element properties.

With TJvSimpleXml.Create(nil) do begin
  LoadFromString('<?xml version="1.0" encoding="iso-8859-1"?><test myprop="Foregin chars:&#xC5;&#xC4;&#xD6;"></test>');
  a:=root.Properties.Value('myprop'); // ÅÄÖ
  tmp:=root.SaveToString;
  b:=root.Properties.Value('myprop'); // &#xC5;&#xC4;&#xD6;
end;
TagsNo tags attached.

Activities

anonymous

2004-11-28 06:09

viewer   ~0005739

Sorry, it should be,
SaveToString has sideeffect of encoding element properties.

user72

2004-11-28 06:56

  ~0005740

JvSimpleXML only supports UTF-8

anonymous

2004-11-28 07:57

viewer   ~0005742

With TJvSimpleXml.Create(nil) do begin
  root.Name:='test';
  root.Properties.Add('myProp','Foregin chars:ÅÄÖ');
  a:=root.Properties.Value('myprop');
  tmp:=root.SaveToString;
  b:=root.Properties.Value('myprop');
end;

Same "bug". a<>b.

user72

2004-11-28 11:03

  ~0005744

As I said, JvSimpleXML only supports UTF-8 which means that when it saves its data, it is converted to UTF8 and all chars > 127 are converted to hex format.

Try loading the resulting string into Internet Explorer and you'll see that it displays the foregin chars correctly.

We are aware that this could be viewed as a serious limitation, but implementing it any other way would mean a considerable effort.

anonymous

2004-11-28 11:57

viewer   ~0005745

UTF-8 is not a issue here. You can find the bug at line 2079 and 2085 in JvSimpleXml.pas.

if AEncoder <> nil then
  AEncoder.DoEncodeValue(FValue);
Result := Format(' %s:%s="%s"', [Pointer, Name, FValue]);

DoEncodeValue takes a VAR argument, resulting i FValue to be permantly encoded. To correct the bug you could use something like;

tmp:=FValue;
if AEncoder <> nil then
  AEncoder.DoEncodeValue(tmp);
Result := Format(' %s:%s="%s"', [Pointer, Name, tmp]);

I hope you can find the effort to make this change :-)

user72

2004-11-28 12:53

  ~0005746

> I hope you can find the effort to make this change :-)
No need to get cute. If you had explained the problem from the beginning, there wouldn't have been any misunderstanding and the problem resolved immediately.

Fixed in CVS

Issue History

Date Modified Username Field Change
2004-11-28 06:04 anonymous New Issue
2004-11-28 06:09 anonymous Note Added: 0005739
2004-11-28 06:56 user72 Note Added: 0005740
2004-11-28 07:57 anonymous Note Added: 0005742
2004-11-28 11:03 user72 Note Added: 0005744
2004-11-28 11:04 user72 Status new => feedback
2004-11-28 11:57 anonymous Note Added: 0005745
2004-11-28 12:53 user72 Status feedback => resolved
2004-11-28 12:53 user72 Resolution open => fixed
2004-11-28 12:53 user72 Assigned To => user72
2004-11-28 12:53 user72 Note Added: 0005746