When I using xmlCfg unit i found problem with storing literals in
arbitrary code page. XMLCfg perform automatic conversion with omit some
chars.
I've change it to use utf8string instead of. Maybe this patch will be
interesting.

Index: packages/fcl-xml/src/xmlcfg.pp
===================================================================
--- packages/fcl-xml/src/xmlcfg.pp	(wersja 15974)
+++ packages/fcl-xml/src/xmlcfg.pp	(kopia robocza)
@@ -66,10 +66,10 @@
     destructor Destroy; override;
     procedure Clear;
     procedure Flush;    // Writes the XML file
-    function  GetValue(const APath, ADefault: String): String; overload;
+    function  GetValue(const APath: String; const ADefault: utf8String): utf8String; overload;
     function  GetValue(const APath: String; ADefault: Integer): Integer; overload;
     function  GetValue(const APath: String; ADefault: Boolean): Boolean; overload;
-    procedure SetValue(const APath, AValue: String); overload;
+    procedure SetValue(const APath: string; const AValue: utf8String); overload;
     procedure SetDeleteValue(const APath, AValue, DefValue: String); overload;
     procedure SetValue(const APath: String; AValue: Integer); overload;
     procedure SetDeleteValue(const APath: String; AValue, DefValue: Integer); overload;
@@ -125,7 +125,7 @@
   end;
 end;

-function TXMLConfig.GetValue(const APath, ADefault: String): String;
+function TXMLConfig.GetValue(const APath: String; const ADefault: utf8String): utf8String;
 var
   Node, Child, Attr: TDOMNode;
   NodeName: String;
@@ -157,7 +157,7 @@
   Move(APath[StartPos], NodeName[1], Length(NodeName));
   Attr := Node.Attributes.GetNamedItem(Escape(NodeName));
   if Assigned(Attr) then
-    Result := Attr.NodeValue;
+    Result := utf8encode(Attr.NodeValue);
 end;

 function TXMLConfig.GetValue(const APath: String; ADefault: Integer): Integer;
@@ -184,10 +184,11 @@
     Result := ADefault;
 end;

-procedure TXMLConfig.SetValue(const APath, AValue: String);
+procedure TXMLConfig.SetValue(const APath: String; const AValue: utf8String);
 var
   Node, Child: TDOMNode;
   NodeName: String;
+  NodeValue: DOMString;
   PathLen: integer;
   StartPos, EndPos: integer;
 begin
@@ -219,10 +220,11 @@
   SetLength(NodeName, PathLen - StartPos + 1);
   Move(APath[StartPos], NodeName[1], Length(NodeName));
   NodeName := Escape(NodeName);
+  NodeValue := utf8Encode(AValue);
   if (not Assigned(TDOMElement(Node).GetAttributeNode(NodeName))) or
-    (TDOMElement(Node)[NodeName] <> AValue) then
+    (TDOMElement(Node)[NodeName] <> NodeValue) then
   begin
-    TDOMElement(Node)[NodeName] := AValue;
+    TDOMElement(Node)[NodeName] := NodeValue;
     FModified := True;
   end;
 end;
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to