Mercurial > emacs
comparison src/print.c @ 42423:fe55eaa5dfb3
(print_object): In multibyte string, use hex escapes.
Use octal only for unibyte strings.
(PRINTPREPARE): Don't ever set Qprint_escape_nonascii.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 30 Dec 2001 03:22:55 +0000 |
parents | e484ddbc92e1 |
children | 21eaf0f81c5d |
comparison
equal
deleted
inserted
replaced
42422:d0809974975f | 42423:fe55eaa5dfb3 |
---|---|
224 { \ | 224 { \ |
225 Lisp_Object string; \ | 225 Lisp_Object string; \ |
226 if (NILP (current_buffer->enable_multibyte_characters) \ | 226 if (NILP (current_buffer->enable_multibyte_characters) \ |
227 && ! print_escape_multibyte) \ | 227 && ! print_escape_multibyte) \ |
228 specbind (Qprint_escape_multibyte, Qt); \ | 228 specbind (Qprint_escape_multibyte, Qt); \ |
229 if (! NILP (current_buffer->enable_multibyte_characters) \ | |
230 && ! print_escape_nonascii) \ | |
231 specbind (Qprint_escape_nonascii, Qt); \ | |
232 if (print_buffer != 0) \ | 229 if (print_buffer != 0) \ |
233 { \ | 230 { \ |
234 string = make_string_from_bytes (print_buffer, \ | 231 string = make_string_from_bytes (print_buffer, \ |
235 print_buffer_pos, \ | 232 print_buffer_pos, \ |
236 print_buffer_pos_byte); \ | 233 print_buffer_pos_byte); \ |
1382 unsigned char *str; | 1379 unsigned char *str; |
1383 int size_byte; | 1380 int size_byte; |
1384 /* 1 means we must ensure that the next character we output | 1381 /* 1 means we must ensure that the next character we output |
1385 cannot be taken as part of a hex character escape. */ | 1382 cannot be taken as part of a hex character escape. */ |
1386 int need_nonhex = 0; | 1383 int need_nonhex = 0; |
1384 int multibyte = STRING_MULTIBYTE (obj); | |
1387 | 1385 |
1388 GCPRO1 (obj); | 1386 GCPRO1 (obj); |
1389 | 1387 |
1390 if (!NULL_INTERVAL_P (XSTRING (obj)->intervals)) | 1388 if (!NULL_INTERVAL_P (XSTRING (obj)->intervals)) |
1391 { | 1389 { |
1402 /* Here, we must convert each multi-byte form to the | 1400 /* Here, we must convert each multi-byte form to the |
1403 corresponding character code before handing it to PRINTCHAR. */ | 1401 corresponding character code before handing it to PRINTCHAR. */ |
1404 int len; | 1402 int len; |
1405 int c; | 1403 int c; |
1406 | 1404 |
1407 if (STRING_MULTIBYTE (obj)) | 1405 if (multibyte) |
1408 { | 1406 { |
1409 c = STRING_CHAR_AND_LENGTH (str + i_byte, | 1407 c = STRING_CHAR_AND_LENGTH (str + i_byte, |
1410 size_byte - i_byte, len); | 1408 size_byte - i_byte, len); |
1411 if (CHAR_VALID_P (c, 0)) | 1409 if (CHAR_VALID_P (c, 0)) |
1412 i_byte += len; | 1410 i_byte += len; |
1426 else if (c == '\f' && print_escape_newlines) | 1424 else if (c == '\f' && print_escape_newlines) |
1427 { | 1425 { |
1428 PRINTCHAR ('\\'); | 1426 PRINTCHAR ('\\'); |
1429 PRINTCHAR ('f'); | 1427 PRINTCHAR ('f'); |
1430 } | 1428 } |
1431 else if (! SINGLE_BYTE_CHAR_P (c) && print_escape_multibyte) | 1429 else if (multibyte && ! ASCII_BYTE_P (c) |
1430 && (print_escape_multibyte || print_escape_nonascii)) | |
1432 { | 1431 { |
1433 /* When multibyte is disabled, | 1432 /* When multibyte is disabled, |
1434 print multibyte string chars using hex escapes. */ | 1433 print multibyte string chars using hex escapes. */ |
1435 unsigned char outbuf[50]; | 1434 unsigned char outbuf[50]; |
1436 sprintf (outbuf, "\\x%x", c); | 1435 sprintf (outbuf, "\\x%x", c); |
1437 strout (outbuf, -1, -1, printcharfun, 0); | 1436 strout (outbuf, -1, -1, printcharfun, 0); |
1438 need_nonhex = 1; | 1437 need_nonhex = 1; |
1439 } | 1438 } |
1440 else if (SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) | 1439 else if (! multibyte |
1440 && SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) | |
1441 && print_escape_nonascii) | 1441 && print_escape_nonascii) |
1442 { | 1442 { |
1443 /* When printing in a multibyte buffer | 1443 /* When printing in a multibyte buffer |
1444 or when explicitly requested, | 1444 or when explicitly requested, |
1445 print single-byte non-ASCII string chars | 1445 print single-byte non-ASCII string chars |