@SAFEWRITE — Writes a line of text to a file, replacing any remapped “safe” characters with their original, possibly dangerous, values.

Syntax:
%@SAFEWRITE[handle,text]

handle:a file handle opened with @FILEOPEN, or - for stdout
text:a line of text to write to the file

A carriage return and line feed will be written to the file after text. The text may or may not be written in Unicode, depending on the value of the //UnicodeOutput option. If //UnicodeOutput=Yes and the output file is empty, a Byte Order Mark (BOM) will be written before the text.

This function returns the number of characters written to the file, not counting any BOM. If an error was detected, -1 will be returned.

Note: All characters in the range U+FF00 through U+FF5F will be replaced with their normal, ASCII equivalents. (If we’re going to mangle Japanese text files, let’s at least mangle them consistently….)

Note: When //UnicodeOutput=No (the default setting), this function is unnecessary. @FILEWRITE or output redirection will work just as well.