X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcharset%2Fcharset.h;h=898bfb5ae89deeffdd0414f420dd017015288acc;hp=257d2860d70122efb407ae2d4d49b84015f72dcc;hb=578da7e7b6265153fa0519035fc52a086a711ac0;hpb=06c4af3163e2bd99999a93a478d1308ea39c5a79 diff --git a/ccan/charset/charset.h b/ccan/charset/charset.h index 257d2860..898bfb5a 100644 --- a/ccan/charset/charset.h +++ b/ccan/charset/charset.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2010 Joseph A. Adams (joeyadams3.14159@gmail.com) + Copyright (C) 2011 Joseph A. Adams (joeyadams3.14159@gmail.com) All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -42,6 +42,16 @@ typedef uint32_t uchar_t; */ bool utf8_validate(const char *str, size_t length); +/* + * Validate a single UTF-8 character. + * @s: Beginning of UTF-8 character. + * @e: End of string. + * + * If it's valid, return its length (1 thru 4). + * If it's invalid or clipped, return 0. + */ +int utf8_validate_char(const char *s, const char *e); + /* * Read a single UTF-8 character starting at @s, * returning the length, in bytes, of the character read.