I had some free time today and wrote a decoder from scratch: entities.c, entities.h.
The only function with external linkage is
size_t decode_html_entities_utf8(char *dest, const char *src);
If src
is a null pointer, the string will be taken from dest
, ie the entities will be decoded in-place. Otherwise, the decoded string will be put in dest
- which should point to a buffer big enough to hold strlen(src) + 1
characters - and src
will be unchanged.
The function will return the length of the decoded string.
Please note that I haven't done any extensive testing, so there's a high probability of bugs...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…