aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/chars.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-17 11:50:20 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-17 11:50:20 +0000
commit1ee1eeda195d12cccd87b8fdfca9e982035a89e7 (patch)
treedc8c759f44513405842fdbdf491a24a9926a28b9 /chars.c
parent6fcb5ea18d95e1cc79dd37b4e2860f4e8c898346 (diff)
downloadmandoc-1ee1eeda195d12cccd87b8fdfca9e982035a89e7.tar.gz
mandoc-1ee1eeda195d12cccd87b8fdfca9e982035a89e7.tar.zst
mandoc-1ee1eeda195d12cccd87b8fdfca9e982035a89e7.zip
Flip on unicode output (via \[uNNNN]) in -T[x]html. Here we go!
Diffstat (limited to 'chars.c')
-rw-r--r--chars.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/chars.c b/chars.c
index 06a2a923..808d70d7 100644
--- a/chars.c
+++ b/chars.c
@@ -1,4 +1,4 @@
-/* $Id: chars.c,v 1.43 2011/05/15 22:29:50 kristaps Exp $ */
+/* $Id: chars.c,v 1.44 2011/05/17 11:50:20 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -138,7 +138,7 @@ mchars_res2cp(struct mchars *arg, const char *p, size_t sz)
}
/*
- * Numbered character to literal character.
+ * Numbered character string to ASCII codepoint.
* This can only be a printable character (i.e., alnum, punct, space) so
* prevent the character from ruining our state (backspace, newline, and
* so on).
@@ -151,10 +151,24 @@ mchars_num2char(const char *p, size_t sz)
if ((i = mandoc_strntou(p, sz, 10)) < 0)
return('\0');
-
return(isprint(i) ? i : '\0');
}
+/*
+ * Hex character string to Unicode codepoint.
+ * If the character is illegal, returns '\0'.
+ */
+int
+mchars_num2uc(const char *p, size_t sz)
+{
+ int i;
+
+ if ((i = mandoc_strntou(p, sz, 16)) < 0)
+ return('\0');
+ /* FIXME: make sure we're not in a bogus range. */
+ return(i > 0x80 && i <= 0x10FFFF ? i : '\0');
+}
+
/*
* Special character to string array.
*/