|
29 | 29 | #include <stddef.h> |
30 | 30 | #include <stdint.h> |
31 | 31 | #include <string.h> |
32 | | -#include <sys/types.h> |
33 | | - |
34 | 32 |
|
35 | 33 | /** @brief Number of bits that make up a type */ |
36 | 34 | #define NUM_BITS(t) (sizeof(t) * BITS_PER_BYTE) |
@@ -647,63 +645,6 @@ static inline int64_t sign_extend_64(uint64_t value, uint8_t index) |
647 | 645 | return (int64_t)(value << shift) >> shift; |
648 | 646 | } |
649 | 647 |
|
650 | | -/** |
651 | | - * @brief Properly truncate a NULL-terminated UTF-8 string |
652 | | - * |
653 | | - * Take a NULL-terminated UTF-8 string and ensure that if the string has been |
654 | | - * truncated (by setting the NULL terminator) earlier by other means, that |
655 | | - * the string ends with a properly formatted UTF-8 character (1-4 bytes). |
656 | | - * |
657 | | - * Example: |
658 | | - * |
659 | | - * @code{.c} |
660 | | - * char test_str[] = "€€€"; |
661 | | - * char trunc_utf8[8]; |
662 | | - * |
663 | | - * printf("Original : %s\n", test_str); // €€€ |
664 | | - * strncpy(trunc_utf8, test_str, sizeof(trunc_utf8)); |
665 | | - * trunc_utf8[sizeof(trunc_utf8) - 1] = '\0'; |
666 | | - * printf("Bad : %s\n", trunc_utf8); // €€� |
667 | | - * utf8_trunc(trunc_utf8); |
668 | | - * printf("Truncated: %s\n", trunc_utf8); // €€ |
669 | | - * @endcode |
670 | | - * |
671 | | - * @param utf8_str NULL-terminated string |
672 | | - * |
673 | | - * @return Pointer to the @p utf8_str |
674 | | - */ |
675 | | -char *utf8_trunc(char *utf8_str); |
676 | | - |
677 | | -/** |
678 | | - * @brief Copies a UTF-8 encoded string from @p src to @p dst |
679 | | - * |
680 | | - * The resulting @p dst will always be NULL terminated if @p n is larger than 0, |
681 | | - * and the @p dst string will always be properly UTF-8 truncated. |
682 | | - * |
683 | | - * @param dst The destination of the UTF-8 string. |
684 | | - * @param src The source string |
685 | | - * @param n The size of the @p dst buffer. Maximum number of characters copied |
686 | | - * is @p n - 1. If 0 nothing will be done, and the @p dst will not be |
687 | | - * NULL terminated. |
688 | | - * |
689 | | - * @return Pointer to the @p dst |
690 | | - */ |
691 | | -char *utf8_lcpy(char *dst, const char *src, size_t n); |
692 | | - |
693 | | -/** |
694 | | - * @brief Counts the characters in a UTF-8 encoded string @p s |
695 | | - * |
696 | | - * Counts the number of UTF-8 characters (code points) in a null-terminated string. |
697 | | - * This function steps through each UTF-8 sequence by checking leading byte patterns. |
698 | | - * It does not fully validate UTF-8 correctness, only counts characters. |
699 | | - * |
700 | | - * @param s The input string |
701 | | - * |
702 | | - * @return Number of UTF-8 characters in @p s on success or (negative) error code |
703 | | - * otherwise. |
704 | | - */ |
705 | | -ssize_t utf8_count_chars(const char *s); |
706 | | - |
707 | 648 | #define __z_log2d(x) (32 - __builtin_clz(x) - 1) |
708 | 649 | #define __z_log2q(x) (64 - __builtin_clzll(x) - 1) |
709 | 650 | #define __z_log2(x) (sizeof(__typeof__(x)) > 4 ? __z_log2q(x) : __z_log2d(x)) |
|
0 commit comments