MCPcopy Create free account
hub / github.com/ElementsProject/lightning / utf8_check

Function utf8_check

common/utils.c:188–204  ·  view source on GitHub ↗

Check for valid UTF-8 */

Source from the content-addressed store, hash-verified

186
187/* Check for valid UTF-8 */
188bool utf8_check(const void *vbuf, size_t buflen)
189{
190 const u8 *buf = vbuf;
191 struct utf8_state utf8_state = UTF8_STATE_INIT;
192 bool need_more = false;
193
194 for (size_t i = 0; i < buflen; i++) {
195 if (!utf8_decode(&utf8_state, buf[i])) {
196 need_more = true;
197 continue;
198 }
199 need_more = false;
200 if (errno != 0)
201 return false;
202 }
203 return !need_more;
204}
205
206char *utf8_str(const tal_t *ctx, const u8 *buf TAKES, size_t buflen)
207{

Callers 7

utf8_strFunction · 0.70
validate_jsmn_datumFunction · 0.70
validate_jsmn_keyvalueFunction · 0.70
htlc_accepted_callFunction · 0.50
json_add_runeFunction · 0.50
fromwire_utf8_arrayFunction · 0.50
towire_utf8_arrayFunction · 0.50

Calls 1

utf8_decodeFunction · 0.85

Tested by

no test coverage detected