tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* -Thtml: Use hexadecimal character references
@ 2017-07-14  1:05 Anthony J. Bentley
  2017-07-14 12:37 ` Ingo Schwarze
  0 siblings, 1 reply; 2+ messages in thread
From: Anthony J. Bentley @ 2017-07-14  1:05 UTC (permalink / raw)
  To: tech

Hi,

Since Unicode codepoints are universally referred to in hexadecimal,
this would make the HTML source easier to reason about while debugging.
I have learned many hexadecimal codepoints over the years, but not a
single one in decimal.

The longest character reference, "&#x10ffff", is the same length as
"&#1114111", so numbuf doesn't need to be increased in size.

Index: html.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/html.c,v
retrieving revision 1.85
diff -u -p -r1.85 html.c
--- html.c	23 Jun 2017 02:31:39 -0000	1.85
+++ html.c	13 Jul 2017 16:11:23 -0000
@@ -451,7 +451,7 @@ print_encode(struct html *h, const char 
 		    (c > 0x7E && c < 0xA0))
 			c = 0xFFFD;
 		if (c > 0x7E) {
-			(void)snprintf(numbuf, sizeof(numbuf), "&#%d;", c);
+			(void)snprintf(numbuf, sizeof(numbuf), "&#x%x;", c);
 			print_word(h, numbuf);
 		} else if (print_escape(h, c) == 0)
 			print_byte(h, c);
@@ -514,7 +514,7 @@ print_otag(struct html *h, enum htmltag 
 		print_indent(h);
 	else if ((h->flags & HTML_NOSPACE) == 0) {
 		if (h->flags & HTML_KEEP)
-			print_word(h, "&#160;");
+			print_word(h, "&#xa0;");
 		else {
 			if (h->flags & HTML_PREKEEP)
 				h->flags |= HTML_KEEP;
@@ -777,7 +777,7 @@ print_text(struct html *h, const char *w
 				h->flags |= HTML_KEEP;
 			print_endword(h);
 		} else
-			print_word(h, "&#160;");
+			print_word(h, "&#xa0;");
 	}
 
 	assert(NULL == h->metaf);
--
 To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-14 12:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-14  1:05 -Thtml: Use hexadecimal character references Anthony J. Bentley
2017-07-14 12:37 ` Ingo Schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).