diff options
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/coding.c b/src/coding.c index 1705838ffad..5ea1e395f20 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6360,6 +6360,27 @@ check_utf_8 (struct coding_system *coding) | |||
| 6360 | } | 6360 | } |
| 6361 | 6361 | ||
| 6362 | 6362 | ||
| 6363 | /* Return whether STRING is a valid UTF-8 string. STRING must be a | ||
| 6364 | unibyte string. */ | ||
| 6365 | |||
| 6366 | bool | ||
| 6367 | utf8_string_p (Lisp_Object string) | ||
| 6368 | { | ||
| 6369 | eassert (!STRING_MULTIBYTE (string)); | ||
| 6370 | struct coding_system coding; | ||
| 6371 | setup_coding_system (Qutf_8_unix, &coding); | ||
| 6372 | /* We initialize only the fields that check_utf_8 accesses. */ | ||
| 6373 | coding.head_ascii = -1; | ||
| 6374 | coding.src_pos = 0; | ||
| 6375 | coding.src_pos_byte = 0; | ||
| 6376 | coding.src_chars = SCHARS (string); | ||
| 6377 | coding.src_bytes = SBYTES (string); | ||
| 6378 | coding.src_object = string; | ||
| 6379 | coding.eol_seen = EOL_SEEN_NONE; | ||
| 6380 | return check_utf_8 (&coding) != -1; | ||
| 6381 | } | ||
| 6382 | |||
| 6383 | |||
| 6363 | /* Detect how end-of-line of a text of length SRC_BYTES pointed by | 6384 | /* Detect how end-of-line of a text of length SRC_BYTES pointed by |
| 6364 | SOURCE is encoded. If CATEGORY is one of | 6385 | SOURCE is encoded. If CATEGORY is one of |
| 6365 | coding_category_utf_16_XXXX, assume that CR and LF are encoded by | 6386 | coding_category_utf_16_XXXX, assume that CR and LF are encoded by |
| @@ -10846,6 +10867,7 @@ syms_of_coding (void) | |||
| 10846 | DEFSYM (Qiso_2022, "iso-2022"); | 10867 | DEFSYM (Qiso_2022, "iso-2022"); |
| 10847 | 10868 | ||
| 10848 | DEFSYM (Qutf_8, "utf-8"); | 10869 | DEFSYM (Qutf_8, "utf-8"); |
| 10870 | DEFSYM (Qutf_8_unix, "utf-8-unix"); | ||
| 10849 | DEFSYM (Qutf_8_emacs, "utf-8-emacs"); | 10871 | DEFSYM (Qutf_8_emacs, "utf-8-emacs"); |
| 10850 | 10872 | ||
| 10851 | #if defined (WINDOWSNT) || defined (CYGWIN) | 10873 | #if defined (WINDOWSNT) || defined (CYGWIN) |