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

Function utf8_check

common/utils.c:173–189  ·  view source on GitHub ↗

Check for valid UTF-8 */

Source from the content-addressed store, hash-verified

171
172/* Check for valid UTF-8 */
173bool utf8_check(const void *vbuf, size_t buflen)
174{
175 const u8 *buf = vbuf;
176 struct utf8_state utf8_state = UTF8_STATE_INIT;
177 bool need_more = false;
178
179 for (size_t i = 0; i < buflen; i++) {
180 if (!utf8_decode(&utf8_state, buf[i])) {
181 need_more = true;
182 continue;
183 }
184 need_more = false;
185 if (errno != 0)
186 return false;
187 }
188 return !need_more;
189}
190
191char *utf8_str(const tal_t *ctx, const u8 *buf TAKES, size_t buflen)
192{

Callers 15

utf8_strFunction · 0.70
validate_jsmn_datumFunction · 0.70
validate_jsmn_keyvalueFunction · 0.70
make_unsigned_proof_Function · 0.70
refresh_completeFunction · 0.50
htlc_accepted_callFunction · 0.50
param_bip353Function · 0.50
param_bolt12_invstringFunction · 0.50
param_decodableFunction · 0.50
json_add_utf8Function · 0.50
json_add_runeFunction · 0.50

Calls 1

utf8_decodeFunction · 0.85

Tested by

no test coverage detected