aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/coding.c b/src/coding.c
index cfb9c74857a..01878a37b5c 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -380,6 +380,9 @@ int inhibit_eol_conversion;
380/* Flag to inhibit ISO2022 escape sequence detection. */ 380/* Flag to inhibit ISO2022 escape sequence detection. */
381int inhibit_iso_escape_detection; 381int inhibit_iso_escape_detection;
382 382
383/* Flag to inhibit detection of binary files through null bytes. */
384int inhibit_null_byte_detection;
385
383/* Flag to make buffer-file-coding-system inherit from process-coding. */ 386/* Flag to make buffer-file-coding-system inherit from process-coding. */
384int inherit_process_coding_system; 387int inherit_process_coding_system;
385 388
@@ -5906,7 +5909,7 @@ detect_coding (coding)
5906 break; 5909 break;
5907 } 5910 }
5908 } 5911 }
5909 else if (! c) 5912 else if (! c && !inhibit_null_byte_detection)
5910 { 5913 {
5911 null_byte_found = 1; 5914 null_byte_found = 1;
5912 if (eight_bit_found) 5915 if (eight_bit_found)
@@ -7790,7 +7793,7 @@ detect_coding_system (src, src_chars, src_bytes, highest, multibytep,
7790 break; 7793 break;
7791 } 7794 }
7792 } 7795 }
7793 else if (! c) 7796 else if (! c && !inhibit_null_byte_detection)
7794 { 7797 {
7795 null_byte_found = 1; 7798 null_byte_found = 1;
7796 if (eight_bit_found) 7799 if (eight_bit_found)
@@ -10295,18 +10298,18 @@ called even if `coding-system-for-write' is non-nil. The command
10295 DEFVAR_BOOL ("inhibit-iso-escape-detection", 10298 DEFVAR_BOOL ("inhibit-iso-escape-detection",
10296 &inhibit_iso_escape_detection, 10299 &inhibit_iso_escape_detection,
10297 doc: /* 10300 doc: /*
10298If non-nil, Emacs ignores ISO2022's escape sequence on code detection. 10301If non-nil, Emacs ignores ISO-2022 escape sequences during code detection.
10299 10302
10300By default, on reading a file, Emacs tries to detect how the text is 10303When Emacs reads text, it tries to detect how the text is encoded.
10301encoded. This code detection is sensitive to escape sequences. If 10304This code detection is sensitive to escape sequences. If Emacs sees
10302the sequence is valid as ISO2022, the code is determined as one of 10305a valid ISO-2022 escape sequence, it assumes the text is encoded in one
10303the ISO2022 encodings, and the file is decoded by the corresponding 10306of the ISO2022 encodings, and decodes text by the corresponding coding
10304coding system (e.g. `iso-2022-7bit'). 10307system (e.g. `iso-2022-7bit').
10305 10308
10306However, there may be a case that you want to read escape sequences in 10309However, there may be a case that you want to read escape sequences in
10307a file as is. In such a case, you can set this variable to non-nil. 10310a file as is. In such a case, you can set this variable to non-nil.
10308Then, as the code detection ignores any escape sequences, no file is 10311Then the code detection will ignore any escape sequences, and no text is
10309detected as encoded in some ISO2022 encoding. The result is that all 10312detected as encoded in some ISO-2022 encoding. The result is that all
10310escape sequences become visible in a buffer. 10313escape sequences become visible in a buffer.
10311 10314
10312The default value is nil, and it is strongly recommended not to change 10315The default value is nil, and it is strongly recommended not to change
@@ -10316,10 +10319,23 @@ in Emacs's distribution, and they won't be decoded correctly on
10316reading if you suppress escape sequence detection. 10319reading if you suppress escape sequence detection.
10317 10320
10318The other way to read escape sequences in a file without decoding is 10321The other way to read escape sequences in a file without decoding is
10319to explicitly specify some coding system that doesn't use ISO2022's 10322to explicitly specify some coding system that doesn't use ISO-2022
10320escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); 10323escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */);
10321 inhibit_iso_escape_detection = 0; 10324 inhibit_iso_escape_detection = 0;
10322 10325
10326 DEFVAR_BOOL ("inhibit-null-byte-detection",
10327 &inhibit_null_byte_detection,
10328 doc: /* If non-nil, Emacs ignores null bytes on code detection.
10329By default, Emacs treats it as binary data, and does not attempt to
10330decode it. The effect is as if you specified `no-conversion' for
10331reading that text.
10332
10333Set this to non-nil when a regular text happens to include null bytes.
10334Examples are Index nodes of Info files and null-byte delimited output
10335from GNU Find and GNU Grep. Emacs will then ignore the null bytes and
10336decode text as usual. */);
10337 inhibit_null_byte_detection = 0;
10338
10323 DEFVAR_LISP ("translation-table-for-input", &Vtranslation_table_for_input, 10339 DEFVAR_LISP ("translation-table-for-input", &Vtranslation_table_for_input,
10324 doc: /* Char table for translating self-inserting characters. 10340 doc: /* Char table for translating self-inserting characters.
10325This is applied to the result of input methods, not their input. 10341This is applied to the result of input methods, not their input.