Recent

Author Topic: Http request return utf-16  (Read 650 times)

SteenJorgensen

  • Jr. Member
  • **
  • Posts: 68
Http request return utf-16
« on: May 25, 2019, 06:32:22 am »

I need help please :o

I have write some code to read a HTTPS GET, and it works fine.
But now i need to use the same code that return a xml-file with unicode utf-16, and this give me error.
   
Code: Pascal  [Select][+][-]
  1. procedure TFormMain.Button2Click(Sender: TObject);
  2. var
  3.   Parser: TDOMParser;
  4.   Src: TXMLInputSource;
  5.   Doc: TXMLDocument;
  6.   Req: String;
  7. begin
  8.   Try
  9.     Parser := TDOMParser.Create;
  10.     Req :='https://mysite.dk/thexmlfile';
  11.     Src := TXMLInputSource.Create(TFPCustomHTTPClient.SimpleGet(Req));
  12.    
  13.     Parser.Options.Validate := True;
  14.     Parser.Parse(Src, Doc);
  15.  
  16.     WriteXMLFile(Doc, 'my.xml');
  17.    


The problems starts already when i initalizer the Scr variabel with feed. (use utf-8????)

Is there a way to get the utf-16 xml file from the feed into a variable than i can handel?
----------------------------------------
Lazarus version 2.0.12 64-bit
FPC 3.2.0

 

TinyPortal © 2005-2018