comparison src/print.c @ 22240:4e4c377f3310

(print_escape_nonascii): New variable. (print) <Lisp_String>: Use it to force printing single-byte non-ASCII characters as octal escapes. (syms_of_print): Define print-escape-nonascii.
author Richard M. Stallman <rms@gnu.org>
date Mon, 25 May 1998 20:29:54 +0000
parents 35af9a276272
children ec7420aa37f3
comparison
equal deleted inserted replaced
22239:0a666cecb85d 22240:4e4c377f3310
127 /* Nonzero means print newlines in strings as \n. */ 127 /* Nonzero means print newlines in strings as \n. */
128 128
129 int print_escape_newlines; 129 int print_escape_newlines;
130 130
131 Lisp_Object Qprint_escape_newlines; 131 Lisp_Object Qprint_escape_newlines;
132
133 /* Nonzero means to print single-byte non-ascii characters in strings as
134 octal escapes. */
135
136 int print_escape_nonascii;
132 137
133 /* Nonzero means print (quote foo) forms as 'foo, etc. */ 138 /* Nonzero means print (quote foo) forms as 'foo, etc. */
134 139
135 int print_quoted; 140 int print_quoted;
136 141
1246 strout (outbuf, -1, -1, printcharfun, 0); 1251 strout (outbuf, -1, -1, printcharfun, 0);
1247 need_nonhex = 1; 1252 need_nonhex = 1;
1248 } 1253 }
1249 else if (SINGLE_BYTE_CHAR_P (c) 1254 else if (SINGLE_BYTE_CHAR_P (c)
1250 && ! ASCII_BYTE_P (c) 1255 && ! ASCII_BYTE_P (c)
1251 && ! NILP (current_buffer->enable_multibyte_characters)) 1256 && (! NILP (current_buffer->enable_multibyte_characters)
1257 || print_escape_nonascii))
1252 { 1258 {
1253 /* When multibyte is enabled, 1259 /* When multibyte is enabled or when explicitly requested,
1254 print single-byte non-ASCII string chars 1260 print single-byte non-ASCII string chars
1255 using octal escapes. */ 1261 using octal escapes. */
1256 unsigned char outbuf[5]; 1262 unsigned char outbuf[5];
1257 sprintf (outbuf, "\\%03o", c); 1263 sprintf (outbuf, "\\%03o", c);
1258 strout (outbuf, -1, -1, printcharfun, 0); 1264 strout (outbuf, -1, -1, printcharfun, 0);
1805 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines, 1811 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines,
1806 "Non-nil means print newlines in strings as backslash-n.\n\ 1812 "Non-nil means print newlines in strings as backslash-n.\n\
1807 Also print formfeeds as backslash-f."); 1813 Also print formfeeds as backslash-f.");
1808 print_escape_newlines = 0; 1814 print_escape_newlines = 0;
1809 1815
1816 DEFVAR_BOOL ("print-escape-nonascii", &print_escape_nonascii,
1817 "Non-nil means print non-ASCII characters in strings as backslash-NNN.\n\
1818 NNN is the octal representation of the character's value.\n\
1819 Only single-byte characters are affected.");
1820 print_escape_nonascii = 0;
1821
1810 DEFVAR_BOOL ("print-quoted", &print_quoted, 1822 DEFVAR_BOOL ("print-quoted", &print_quoted,
1811 "Non-nil means print quoted forms with reader syntax.\n\ 1823 "Non-nil means print quoted forms with reader syntax.\n\
1812 I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\ 1824 I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\
1813 forms print in the new syntax."); 1825 forms print in the new syntax.");
1814 print_quoted = 0; 1826 print_quoted = 0;