Syntax
| Send sText$ [, bIncludeEOL]
| ||||||
|---|---|---|---|---|---|---|---|
Description
| Writes a string to the HTTP response body of the current request, with automatic UTF-8 encoding and automatic Content-Type header management. Send is the standard CCL output statement and should be used for all textual responses, including HTML pages, JSON payloads, XML documents, and plain text output.
Before writing the payload, Send inspects the current Content-Type header on the response. When no Content-Type header has been set by the script, Send assigns the default "text/html; charset=utf-8". When a Content-Type header is already present but does not include a charset parameter, Send upgrades it by appending "; charset=utf-8". When a Content-Type header is already present with charset=utf-8, Send leaves it as it is. When a Content-Type header is already present with a different charset, Send writes the payload as-is and performs no encoding conversion, allowing scripts to deliberately produce output in another character set when required.
After header management, Send converts the payload from its native CCL representation into proper UTF-8 byte sequences and writes the result to the response body. This guarantees that extended characters such as German umlauts, French accents, the Euro sign, and any other non-ASCII content are transmitted correctly to the client and decoded without loss by modern browsers, REST clients, and parsers that follow the declared charset.
Send replaces the older direct ParentResponse.Body.Write pattern, which produced single-byte Windows-1252 output regardless of the declared charset and was the source of mojibake in responses containing extended characters. Existing scripts that contain only ASCII content behave identically under Send and need no modification. Scripts that produce extended characters benefit immediately from correct UTF-8 output without any further code changes.
For legacy Windows-1252 output use SendAnsi.
For raw binary payloads such as images or PDF documents use SendBinary.
| ||||||
See Also
| |||||||
Example
| Sub Main
Dim sJson As String
Dim sGerman As String
sGerman = "Fuer den Archivierungsprozess: " & _
Chr$(252) & Chr$(228) & Chr$(246) & Chr$(223)
sJson = "{""status"":""ok"",""message"":""" & sGerman & """}"
ParentResponse.Header.Add httpContentType, "application/json", True
Send sJson
ParentResponse.Status = httpOK
ParentResponse.Send
End Sub
|