Hello,

when i saving unicode text to file with TXMLConfig (from "Laz_XMLCfg") i get correct results (code below, first part), but if use TXMLDocument (secont part of code) i get messed unicode text in file. Why?? What i doing wrong?

// code (on form placed two labels):

unit Unit1;

{$mode objfpc}{$H+}

interface

uses laz_xmlcfg, DOM, XMLRead, XMLWrite,
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
const
  FAILAS='testas.config';
  SAKA='testas/eilute';
  TESTAS='-ąčęėįšųūž-ĄČĘĖĮŠŲŪŽ-';
var
  xmlcfg: TXMLConfig;
  xml_doc: TXMLDocument;
  node_00, node_01: TDOMNode;
begin
    DeleteFile(FAILAS);
    //==== using TXMLConfig =============================
    xmlcfg:=TXMLConfig.Create(FAILAS);
    xmlcfg.SetValue(SAKA, TESTAS);
    xmlcfg.Flush;
    xmlcfg.Free;
    //
    xmlcfg:=TXMLConfig.Create(FAILAS);
    Label1.Caption:='>'+xmlcfg.GetValue(SAKA, '')+'<';
    xmlcfg.Free;
    //
    DeleteFile(FAILAS);
    //==== using TXMLDocument ===========================
    xml_doc:=TXMLDocument.Create;
    node_00:=xml_doc.CreateElement('root');
    xml_doc.AppendChild(node_00);
    node_00:=xml_doc.DocumentElement;
    node_01:=xml_doc.CreateElement('kitas_testas');
    node_00.AppendChild(node_01);
    TDOMElement(node_01)['kita_eilute']:=TESTAS;
    WriteXMLFile(xml_doc, FAILAS);
    xml_doc.Free;
    //
    xml_doc:=TXMLDocument.Create;
    ReadXMLFile(xml_doc, FAILAS);
    node_00:=xml_doc.FindNode('root');
    node_01:=node_00.FindNode('kitas_testas');
    Label2.Caption:='>'+TDOMElement(node_01)['kita_eilute']+'<';
    xml_doc.Free;
end;

initialization
  {$I unit1.lrs}

end.



--
  Valdas Jankūnas

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to