Files
damus/nostrdb/ccan/ccan/utf8/_info
Rusty Russell a8d7d971b1 nostrdb: ccan: sync with normal versions.
This is the version of CCAN which CLN was using at the time these
were taken.  Unfortunately lots of whitespace has been changed,
but AFAICT no source changes.

Here's the command I ran (with ../ccan checked out to 1ae4c432):

```
make update-ccan CCAN_NEW="alignof array_size build_assert check_type container_of cppmagic likely list mem short_types str structeq take tal tal/str typesafe_cb utf8 endian crypto/sha256"
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: William Casarin <jb55@jb55.com>
2025-08-11 16:40:00 -07:00

49 lines
1.0 KiB
Plaintext

#include "config.h"
#include <stdio.h>
#include <string.h>
/**
* utf8 - Simple routines to encode/decode valid UTF-8.
*
* This code contains routines to encode and decode UTF-8 characters.
* Table and test code stolen entirely from:
* Copyright (c) 2017 Christian Hansen <chansen@cpan.org>
* <https://github.com/chansen/c-utf8-valid>
*
* Example:
* int main(int argc, char *argv[])
* {
* size_t i;
* struct utf8_state utf8_state = UTF8_STATE_INIT;
* bool decoded = true;
*
* for (i = 0; i < strlen(argv[1]); i++) {
* decoded = utf8_decode(&utf8_state, argv[1][i]);
* if (decoded) {
* if (errno != 0)
* err(1, "Invalid UTF8 char %zu-%zu",
* i - utf8_state.used_len, i);
* printf("Character %u\n", utf8_state.c);
* }
* }
*
* if (!decoded)
* errx(1, "Incomplete UTF8");
* return 0;
* }
*
* License: BSD-MIT
*/
int main(int argc, char *argv[])
{
/* Expect exactly one argument */
if (argc != 2)
return 1;
if (strcmp(argv[1], "depends") == 0) {
return 0;
}
return 1;
}