link-grammar-5.8.0/link-grammar/print/print-util.c
/**
 * Append exactly one UTF-8 character to the string.
 * Return the number of bytes to advance, until the
 * next UTF-8 character. This might NOT be the same as
 * number of bytes actually appended. Two things might
 * happen:
 * a) Invalid UTF-8 values are copied, but only one byte,
 *    followed by an additional blank.
 * b) Valid UTF-8 code-points that do not have a known
 *    glyph are copied, followed by an additional blank.
 * This additional blanks allows proper printing of these
 * two cases, by allowing the terminal to display with
 * "box fonts" - boxes containing hex code, usually two
 * column-widths wide.
 */
Append exactly one UTF-8 character to the string.
Return the number of bytes to advance, until the
next UTF-8 character. This might NOT be the same as
number of bytes actually appended. Two things might
happen:
a) Invalid UTF-8 values are copied, but only one byte,
followed by an additional blank.
b) Valid UTF-8 code-points that do not have a known
glyph are copied, followed by an additional blank.
This additional blanks allows proper printing of these
two cases, by allowing the terminal to display with
"box fonts" - boxes containing hex code, usually two
column-widths wide.
Append exactly one UTF - 8 character to the string . Return the number of bytes to advance until the next UTF - 8 character . This might NOT be the same as number of bytes actually appended . Two things might happen : a ) Invalid UTF - 8 values are copied but only one byte followed by an additional blank . b ) Valid UTF - 8 code - points that do not have a known glyph are copied followed by an additional blank . This additional blanks allows proper printing of these two cases by allowing the terminal to display with " box fonts " - boxes containing hex code usually two column - widths wide .
size_t append_utf8_char(dyn_str * string, const char * mbs)
{
	char buf[12];
	assert('\0' != *mbs);
	int nb = utf8_charlen(mbs);
	int n = nb;
	if (n < 0) n = 1; 
	assert((size_t)n<sizeof(buf), "Multi-byte character is too long!");
	memcpy(buf, mbs, n);
	if (nb < 0) { buf[n] = ' '; n++; }
	if (0 < nb && utf8_charwidth(mbs) < 0) { buf[n] = ' '; n++; }
	buf[n] = 0;
	dyn_strcat(string, buf);
	n = nb;
	if (n < 0) n = 1; 
	return n;
}
size_t append_utf8_char ( dyn_str * string , const char * mbs ) { char buf [ 12 ] ; assert ( ' \0 ' != * mbs ) ; int nb = utf8_charlen ( mbs ) ; int n = nb ; if ( n < 0 ) n = 1 ; assert ( ( size_t ) n < sizeof ( buf ) , " " ) ; memcpy ( buf , mbs , n ) ; if ( nb < 0 ) { buf [ n ] = ' ' ; n ++ ; } if ( 0 < nb && utf8_charwidth ( mbs ) < 0 ) { buf [ n ] = ' ' ; n ++ ; } buf [ n ] = 0 ; dyn_strcat ( string , buf ) ; n = nb ; if ( n < 0 ) n = 1 ; return n ; }
Append exactly one UTF-8 character to the string.
Append exactly one UTF - 8 character to the string .
/* Copy exactly one multi-byte character to buf */ // charlen is negative if its not a valid UTF-8 // Whitespace pad if its a bad value // Whitespace pad if not a known UTF-8 glyph. // Null terminate. // How many bytes did we hoover in? // advance exactly one byte, if invalid UTF-8