Recent

Author Topic: [SOLVED] How do I load an .LPI file with Copyright Symbol in the XML?  (Read 508 times)

KevinOfOz

  • New member
  • *
  • Posts: 7
I have a Lazarus project where the .lpi file has a copyright symbol © (alt 0169) in the version information string. I need to be able to read this lpi file to extract various project settings for some internal deployment and documentation tools.

Relevant fragment of the LPI file:
Code: XML  [Select][+][-]
  1.  <?xml version="1.0" encoding="UTF-8"?>
  2. <CONFIG>
  3.   <ProjectOptions>
  4.     <VersionInfo>
  5.       <UseVersionInfo Value="True"/>
  6.       <AutoIncrementBuild Value="True"/>
  7.       <MajorVersionNr Value="1"/>
  8.       <MinorVersionNr Value="5"/>
  9.       <BuildNr Value="63"/>
  10.       <StringTable LegalCopyright="©My Company 2019-2021"/>
  11.     </VersionInfo>
  12.   </ProjectOptions>
  13. </CONFIG>

Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. uses
  4.   DOM,XMLRead,SysUtils;
  5.  
  6. var
  7.   Doc: TXMLDocument;
  8. begin
  9.   Doc:=TXMLDocument.Create;
  10.   try
  11.     try
  12.       ReadXMLFile(Doc,'sample.lpi');
  13.     except
  14.       on E:Exception do
  15.         Writeln(E.ClassName,' : ',E.Message);
  16.     end;
  17.   finally
  18.     Doc.Free;
  19.     Write('Press Enter to close:');
  20.     ReadLn;
  21.   end;
  22. end.

Results in
Quote
EXMLReadError : In 'file:sample.lpi' (line 10 pos 36): Invalid character in input stream
Press Enter to close:

How can I load this XML?
« Last Edit: April 26, 2021, 05:21:38 pm by KevinOfOz »

wp

  • Hero Member
  • *****
  • Posts: 8353
Re: How do I load an .LPI file with Copyright Symbol in the XML?
« Reply #1 on: April 26, 2021, 05:13:03 pm »
Add package LazUtils to the requirements of your project and then replace units DOM and XMLRead by Laz2_DOM and Laz2_XMRead, respectively, to get the utf8 versions of these units:
Code: Pascal  [Select][+][-]
  1. uses
  2.   Laz2_DOM, Laz2_XMLRead, SysUtils;      
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

KevinOfOz

  • New member
  • *
  • Posts: 7
Re: [SOLVED] How do I load an .LPI file with Copyright Symbol in the XML?
« Reply #2 on: April 26, 2021, 05:22:47 pm »
Thanks, that has fixed it.

 

TinyPortal © 2005-2018