Why does IsUTF8String return false?
I have some simple code:
开发者_StackOverflow社区procedure TForm1.Button1Click(Sender:TObject);
var
x: RawByteString;
begin
x := UTF8Encode('testing utf8');
if (IsUTF8String(x)) then
Memo1.Lines.Add('true');
end;
This returns False, am I doing something wrong?
There are no special characters in that string that would require UTF-8 encoding — there are no multibyte UTF-8 sequences in the string. It looks like a plain ASCII string.
If there's anything you can do to the design of your program that would eliminate the need to guess about the encodings of your strings, I recommend you do it. Guesses can be wrong. Try not to be wrong about your customers' data.
精彩评论