System.JSON.Utils.TJsonTextUtils.WriteEscapedString

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

class procedure WriteEscapedString(const Writer: TTextWriter; const Str: string; Delimiter: Char;  AppendDelimiters: Boolean; const CharEscapeFlags: array of Boolean; StringEscapeHandling: TJsonStringEscapeHandling; var WriteBuffer: TCharArray);

C++

__classmethod void __fastcall WriteEscapedString(System::Classes::TTextWriter* const Writer, const System::UnicodeString Str, System::WideChar Delimiter, bool AppendDelimiters, const bool *CharEscapeFlags, const int CharEscapeFlags_High, System::Json::Types::TJsonStringEscapeHandling StringEscapeHandling, System::DynamicArray<System::WideChar> &WriteBuffer);

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.JSON.Utils.pas
System.JSON.Utils.hpp
System.JSON.Utils TJsonTextUtils

Description

Generates a JSON string from a given string.

WriteEscapedString receives the following parameters:

  • Writer is the text writer that WriteEscapedString uses to generate the resulting JSON string.
  • Str is the string to convert into a JSON string.
  • AppendDelimiters determines whether the resulting string is surrounded by quotation characters (True) or not (False).
  • Delimiter is the quotation character to add both at the beginning and at the end of the resulting JSON string if AppendDelimiters is True. For the resulting JSON string to be a proper JSON string, this character must be either a single quote (') or a double quote (").
  • CharEscapeFlags is an array of character escaping flags. For more information, see Character Escaping below.
  • StringEscapeHandling determines the type of character escaping that WriteEscapedString uses.
  • WriteBuffer is a buffer that WriteEscapedString uses internally.

Character Escaping

WriteEscapedString escapes:

WriteEscapedString escapes most characters using Unicode escaping sequences. The following table shows the only characters that WriteEscapedString escapes differently:

Character Escaped Character

Tab

\t

New line

\n

Carriage return

\r

Form feed

\f

Backspace

\b

Backslash

\\

Double quote*

\"

Single quote*

\'

* If StringEscapeHandling is TJsonStringEscapeHandling.EscapeHtml, WriteEscapedString escapes single quotes and double quotes using Unicode escaping sequences.

See Also