Strange behavior from StringList on OpenBSD unix lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- BSaidus · 2024-03-21 22:03 Hello, I have write a simple FPC/Laz CGI program, it consists of saving a hostname into /etc/myname & saving the domain part of the hostname in /etc/resolv.conf. Here is the code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure llp_myname_resolv_conf(const Ahostname: String; const Adomain: String);{$ifdef UNIX}const  cResolv ='/etc/resolv.conf';  cMyname ='/etc/myname';begin  with TStringList.Create() do  begin    try      Clear();      Add( Trim( Ahostname ) );      SaveToFile(cMyname);     Clear();      Add('search '+ Trim( Adomain ) );      Add('nameserver 127.0.0.1');      Add('lookup file bind');      SaveToFile(cResolv);     finally      Free;    end;  end;{$else}begin{$endif}end; The strange thing is that for the /etc/myname, it convert the encoding from UTF-8 to UTF-8-BOM but for the /etc/resolv.conf it is OK. I use TFPHttpClient to Post Form data. I've deleted the /etc/myname & recreate on on the console to be sur that the encoding is correct (UTF8) but every time I resend data the problem raise again. The big problem is the displaying on terminal is horrible. See the screenshots ---------------------------------------------------------------------- paweld · 2024-03-22 06:43 And have you tried forcing BOM off - something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure llp_myname_resolv_conf(const Ahostname: String; const Adomain: String);{$ifdef UNIX}const  cResolv ='/etc/resolv.conf';  cMyname ='/etc/myname';begin  with TStringList.Create() do  begin    WriteBOM := False;    try      Clear();      Add( Trim( Ahostname ) );      SaveToFile(cMyname, Encoding.UTF8);       Clear();      Add('search '+ Trim( Adomain ) );      Add('nameserver 127.0.0.1');      Add('lookup file bind');      SaveToFile(cResolv, Encoding.UTF8);     finally    Free;    end;  end;{$else}begin{$endif}end; ---------------------------------------------------------------------- BSaidus · 2024-03-22 08:15 Thanks @paweld. I'll try & feed back.