Hi!
I have a service write in FPC running (no UI) under linux.
I got a problem when compare a string is "valid"
OS Debian 9, FPC version 3.2.2
here is the code
const valid_text2 = 'ơâABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .';
var s : string;
sw : UnicodeString;
i : integer;
begin
s := 'Sơn tây';
sw := s;
for i := 1 to length(s) do
if pos(sw[i], valid_text2) <= 0 then
Writeln('index = ', i, ', value = ', ord(sw[i]), ' => ', ' not valid');
end.
result is
index = 2, value = 198 => not valid
index = 3, value = 161 => not valid
index = 7, value = 195 => not valid
index = 8, value = 162 => not valid
after looking i found out fpc convert my unicode string to utf8 string, that's why my code doesn't work anymore compare to Delphi in Windows.
In Windows char 2 = 417 and char index 6 = 226.
How i convert that unicode string with encoded by fpc in utf8 to REAL unicode UTF-16 ?