Forum > General

[SOLVED] How do I load an .LPI file with Copyright Symbol in the XML?

(1/1)

KevinOfOz:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- <?xml version="1.0" encoding="UTF-8"?><CONFIG>  <ProjectOptions>    <VersionInfo>      <UseVersionInfo Value="True"/>      <AutoIncrementBuild Value="True"/>      <MajorVersionNr Value="1"/>      <MinorVersionNr Value="5"/>      <BuildNr Value="63"/>      <StringTable LegalCopyright="©My Company 2019-2021"/>    </VersionInfo>  </ProjectOptions></CONFIG>

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project1; uses  DOM,XMLRead,SysUtils; var  Doc: TXMLDocument;begin  Doc:=TXMLDocument.Create;  try    try      ReadXMLFile(Doc,'sample.lpi');    except      on E:Exception do        Writeln(E.ClassName,' : ',E.Message);    end;  finally    Doc.Free;    Write('Press Enter to close:');    ReadLn;  end;end.
Results in

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

How can I load this XML?

wp:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  Laz2_DOM, Laz2_XMLRead, SysUtils;      

KevinOfOz:
Thanks, that has fixed it.

Navigation

[0] Message Index

Go to full version