diff options
| -rw-r--r-- | unicode/book.xml | 12 | ||||
| -rw-r--r-- | unicode/docbook/book.css | 4 | ||||
| -rw-r--r-- | unicode/enttest.c | 16 | ||||
| -rw-r--r-- | unicode/unicode_categories.c | 2 | ||||
| -rw-r--r-- | unicode/unicode_htmlent.c | 34 | 
5 files changed, 59 insertions, 9 deletions
| diff --git a/unicode/book.xml b/unicode/book.xml index 544b47f..17d63ce 100644 --- a/unicode/book.xml +++ b/unicode/book.xml @@ -59,7 +59,7 @@ See COPYING for distribution information.      </listitem>      <listitem>        <para> -	Look up +	Look up the  	<ulink url="http://www.unicode.org/reports/tr24/tr24-&tr24ver;.html">Unicode  	script property</ulink>.        </para> @@ -99,7 +99,7 @@ See COPYING for distribution information.      <para>        To use the library, <quote>#include <courier-unicode.h></quote> and link -      with <literal>-lunicode</literal>. +      with <literal>-lcourier-unicode</literal>.        The starting point is        <link linkend="courier-unicode">  	<citerefentry> @@ -685,6 +685,14 @@ See COPYING for distribution information.  	  </para>  	  <para> +	    Additionally, +	    <function>unicode_html40ent_lookup</function>() parses +	    a numerical entity given as +	    <quote>#<replaceable>decimal</replaceable></quote> or +	    <quote>#x<replaceable>hex</replaceable></quote>. +	  </para> + +	  <para>  	    <function>unicode_html40ent_lookup</function>() returns 0 if the  	    <parameter>entity</parameter> is not a known entity that represents  	    a single unicode character. diff --git a/unicode/docbook/book.css b/unicode/docbook/book.css index 1f893ad..d1420cd 100644 --- a/unicode/docbook/book.css +++ b/unicode/docbook/book.css @@ -44,8 +44,9 @@ code.computeroutput div.literallayout {      font-weight: bold;  } -.command, .acronym { +.command, .acronym, .symbol {      font-family: "liberation mono", "courier new", monospace; +    background-color: #eeeeee;  }  div.blockquote-title { @@ -152,4 +153,3 @@ a:link, a:visited {  #externallinks th, #externallinks td {      border-width: 0px;  } - diff --git a/unicode/enttest.c b/unicode/enttest.c index 0424272..aa9f208 100644 --- a/unicode/enttest.c +++ b/unicode/enttest.c @@ -46,6 +46,22 @@ static void testsuite()  			exit(1);  		}  	} + +	if (unicode_html40ent_lookup("#13") != 13 || +	    unicode_html40ent_lookup("#x100") != 256) +	{ +		fprintf(stderr, "numeric lookup failed\n"); +		exit(1); +	} + +	if (!unicode_isalpha('A') || !unicode_isupper('A') || +	    !unicode_islower('a') || !unicode_isdigit('0') || +	    !unicode_isspace(' ') || !unicode_isblank('\t') || +	    !unicode_ispunct('[')) +	{ +		fprintf(stderr, "category lookup failed\n"); +		exit(1); +	}  }  int main(int argc, char **argv) diff --git a/unicode/unicode_categories.c b/unicode/unicode_categories.c index 9353dbf..bdbdbe1 100644 --- a/unicode/unicode_categories.c +++ b/unicode/unicode_categories.c @@ -59,7 +59,7 @@ int unicode_isdigit(unicode_char ch)  int unicode_isalnum(unicode_char ch)  { -	return unicode_is_alpha(ch) || unicode_is_digit(ch); +	return unicode_isalpha(ch) || unicode_isdigit(ch);  }  int unicode_isgraph(unicode_char ch) diff --git a/unicode/unicode_htmlent.c b/unicode/unicode_htmlent.c index c98f43d..b1111ce 100644 --- a/unicode/unicode_htmlent.c +++ b/unicode/unicode_htmlent.c @@ -44,10 +44,36 @@ static int compar(const void *key, const void *obj)  unicode_char unicode_html40ent_lookup(const char *n)  { -	const struct i *ptr= -		(const struct i *)bsearch(n, ii, -					  sizeof(ii)/sizeof(ii[0]), -					  sizeof(ii[0]), compar); +	const struct i *ptr; + +	if (*n == '#') +	{ +		const char *p=n; +		unicode_char uc; +		char *endptr; + +		++p; + +		if (*p == 'x' || *p == 'X') +		{ +			if (*++p) +			{ +				uc=strtoull(p, &endptr, 16); + +				if (*endptr == 0) +					return uc; +			} +		} + +		uc=strtoull(p, &endptr, 10); + +		if (*endptr == 0) +			return uc; +	} + +	ptr=(const struct i *)bsearch(n, ii, +				      sizeof(ii)/sizeof(ii[0]), +				      sizeof(ii[0]), compar);  	if (ptr)  		return ptr->v; | 
