I have this example of program:
program enctest;
uses
SysUtils, Classes;
var
s: string;
b: TBytes;
f: TFileStream;
begin
s := 'zФ';
b := TEncoding.Convert(TEncoding.UTF8, TEncoding.GetEncoding(1251), BytesOf(s));
f := TFileStream.Create('output.txt', fmOpenWrite);
f.WriteBuffer(Pointer(b)^, Length(b));
f.Free;
end.
This program works fine if it is compiled on Windows. If it is compiled on Linux text is not converted to win1251 encoding and is saved to file as UTF-8. Why? This source is saved as UTF-8 text and s variable has UTF-8 encoding. BytesOf retrieves correct bytes from s, but TEncoding.Convert does nothing insted of converting bytes to win1251.
Im using Xubuntu 14.04 and FPC 3.0.4 with Lazarus 1.8, installed from deb pakages.