mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Modify read and print of combining characters
Since combining characters, such as accents, modify the appearance of the previous letter, it looks awkward in its character literal form (#\name) since it modified the backslash. This instead prints the combining character on a small circle. * libguile/chars.h (SCM_CODEPOINT_DOTTED_CIRCLE): new #define * libguile/print.c (iprint1): print combining characters on dotted circles * libguile/read.c (scm_read_character): parse the combination of combining characters and dotted circles
This commit is contained in:
parent
aa2cba9c88
commit
0dcd7e6153
3 changed files with 20 additions and 3 deletions
|
@ -47,9 +47,10 @@ typedef scm_t_int32 scm_t_wchar;
|
|||
? SCM_MAKE_ITAG8 ((scm_t_bits) (unsigned char) (x), scm_tc8_char) \
|
||||
: SCM_MAKE_ITAG8 ((scm_t_bits) (x), scm_tc8_char))
|
||||
|
||||
#define SCM_CODEPOINT_MAX (0x10ffff)
|
||||
#define SCM_CODEPOINT_DOTTED_CIRCLE (0x25cc)
|
||||
#define SCM_CODEPOINT_SURROGATE_START (0xd800)
|
||||
#define SCM_CODEPOINT_SURROGATE_END (0xdfff)
|
||||
#define SCM_CODEPOINT_MAX (0x10ffff)
|
||||
#define SCM_IS_UNICODE_CHAR(c) \
|
||||
(((scm_t_wchar) (c) >= 0 \
|
||||
&& (scm_t_wchar) (c) < SCM_CODEPOINT_SURROGATE_START) \
|
||||
|
|
|
@ -463,13 +463,26 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
|
|||
/* Print the character if is graphic character. */
|
||||
{
|
||||
scm_t_wchar *wbuf;
|
||||
SCM wstr = scm_i_make_wide_string (1, &wbuf);
|
||||
SCM wstr;
|
||||
char *buf;
|
||||
size_t len;
|
||||
const char *enc;
|
||||
|
||||
enc = scm_i_get_port_encoding (port);
|
||||
wbuf[0] = i;
|
||||
if (uc_combining_class (i) == UC_CCC_NR)
|
||||
{
|
||||
wstr = scm_i_make_wide_string (1, &wbuf);
|
||||
wbuf[0] = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Character is a combining character: print it connected
|
||||
to a dotted circle instead of connecting it to the
|
||||
backslash in '#\' */
|
||||
wstr = scm_i_make_wide_string (2, &wbuf);
|
||||
wbuf[0] = SCM_CODEPOINT_DOTTED_CIRCLE;
|
||||
wbuf[1] = i;
|
||||
}
|
||||
if (enc == NULL)
|
||||
{
|
||||
if (i <= 0xFF)
|
||||
|
|
|
@ -844,6 +844,9 @@ scm_read_character (scm_t_wchar chr, SCM port)
|
|||
return SCM_MAKE_CHAR (scm_i_string_ref (charname, 0));
|
||||
|
||||
cp = scm_i_string_ref (charname, 0);
|
||||
if (cp == SCM_CODEPOINT_DOTTED_CIRCLE && charname_len == 2)
|
||||
return SCM_MAKE_CHAR (scm_i_string_ref (charname, 1));
|
||||
|
||||
if (cp >= '0' && cp < '8')
|
||||
{
|
||||
/* Dirk:FIXME:: This type of character syntax is not R5RS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue