plainTextToStringUtf8

plainTextToStringUtf8(utf8: StringUtf8 output): Integer;

The plainTextToStringUtf8 method of the String primitive type assigns a UTF8 string to the value of the utf8 output parameter. The plain text of the receiver is converted to UTF8 format with any escaped character sequences being replaced by the appropriate UTF8 character.

The method returns zero (0) if the entire string is converted successfully. If an invalid escaped character sequence is encountered, the plainTextToStringUtf8 method returns the offset of the first character in error and the utf8 parameter contains the result of the conversion up to the invalid character.

In the following example, the character sequence © is recognized as a valid character © but the character sequence &cool; is not recognized. The invalid character starts at position 14.

vars
    str : String;
    str8 : StringUtf8;
begin
    str := "© Jade &cool; Software";
    write str.plainTextToStringUtf8(str8);    // 14
    write str8;                               // © Jade
end;