1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-26 05:00:28 +02:00

Beginnings of supporting encoding text in ports.c

* libguile/ports.h (scm_c_put_latin1_chars, scm_c_put_utf32_chars)
  (scm_c_put_char, scm_c_put_string, scm_print_string): New public
  functions.  The plan is to move encoding to ports.c and out of
  print.c.
* libguile/ports.c (UTF8_BUFFER_SIZE, ESCAPE_BUFFER_SIZE): New internal
  defines.
  (update_port_position): Take a position instead of a port.  Update
  callers.
  (utf8_to_codepoint): Allow lengths that are larger than necessary.
  (port_clear_stream_start_for_bom_write): Require that io_mode be
  BOM_IO_TEXT to write a BOM.
  (scm_fill_input): Add a related comment about BOM handling.
  (scm_i_write): use BOM_IO_TEXT, at least for now.
  (encode_escape_sequence, codepoint_to_utf8, utf8_to_codepoint)
  (put_utf8_chars_to_iconv_port, put_latin1_chars_to_utf8_port)
  (put_latin1_chars_to_iconv_port, put_utf32_chars_to_latin1_port)
  (put_utf32_chars_to_utf8_port, put_utf32_chars_to_iconv_port): New
  helpers.
  (scm_putc, scm_puts): Use scm_c_put_char and scm_put_latin1_chars.
This commit is contained in:
Andy Wingo 2016-05-26 23:06:32 +02:00
parent 1123002a9e
commit 43b6feeb1a
2 changed files with 480 additions and 31 deletions

View file

@ -211,10 +211,17 @@ SCM_INTERNAL SCM scm_port_write_buffer (SCM port);
SCM_INTERNAL SCM scm_port_auxiliary_write_buffer (SCM port);
/* Output. */
SCM_API void scm_putc (char c, SCM port);
SCM_API void scm_puts (const char *str_data, SCM port);
SCM_API void scm_c_write (SCM port, const void *buffer, size_t size);
SCM_API void scm_c_write_bytes (SCM port, SCM src, size_t start, size_t count);
SCM_API void scm_c_put_latin1_chars (SCM port, const scm_t_uint8 *buf,
size_t len);
SCM_API void scm_c_put_utf32_chars (SCM port, const scm_t_uint32 *buf,
size_t len);
SCM_API void scm_c_put_string (SCM port, SCM str, size_t start, size_t count);
SCM_API SCM scm_put_string (SCM port, SCM str, SCM start, SCM count);
SCM_API void scm_c_put_char (SCM port, scm_t_wchar ch);
SCM_API void scm_putc (char c, SCM port);
SCM_API void scm_puts (const char *str_data, SCM port);
SCM_API void scm_lfwrite (const char *ptr, size_t size, SCM port);
SCM_INTERNAL void scm_lfwrite_substr (SCM str, size_t start, size_t end,
SCM port);