to_case.sh (1616B)
1 if [ "$ENCODING" = "utf8" ]; then 2 UNIT="byte" 3 ARRAYTYPE="UTF-8-encoded string" 4 SUFFIX="_utf8" 5 ANTISUFFIX="" 6 DATATYPE="char" 7 else 8 UNIT="codepoint" 9 ARRAYTYPE="codepoint array" 10 SUFFIX="" 11 ANTISUFFIX="_utf8" 12 DATATYPE="uint_least32_t" 13 fi 14 15 cat << EOF 16 .Dd ${MAN_DATE} 17 .Dt GRAPHEME_TO_$(printf "%s%s" "$CASE" "$SUFFIX" | tr [:lower:] [:upper:]) 3 18 .Os suckless.org 19 .Sh NAME 20 .Nm grapheme_to_${CASE}${SUFFIX} 21 .Nd convert ${ARRAYTYPE} to ${CASE} 22 .Sh SYNOPSIS 23 .In grapheme.h 24 .Ft size_t 25 .Fn grapheme_to_${CASE}${SUFFIX} "const ${DATATYPE} *src" "size_t srclen" "${DATATYPE} *dest" "size_t destlen" 26 .Sh DESCRIPTION 27 The 28 .Fn grapheme_to_${CASE}${SUFFIX} 29 function converts the ${ARRAYTYPE} 30 .Va str 31 to ${CASE} and writes the result to 32 .Va dest 33 up to 34 .Va destlen , 35 unless 36 .Va dest 37 is set to 38 .Dv NULL . 39 .Pp 40 If 41 .Va srclen 42 is set to 43 .Dv SIZE_MAX 44 (stdint.h is already included by grapheme.h) the ${ARRAYTYPE} 45 .Va src 46 is interpreted to be NUL-terminated and processing stops when a 47 NUL-byte is encountered. 48 .Pp 49 For $(if [ "$ENCODING" != "utf8" ]; then printf "UTF-8-encoded"; else printf "non-UTF-8"; fi) input data 50 .Xr grapheme_to_${CASE}${ANTISUFFIX} 3 51 can be used instead. 52 .Sh RETURN VALUES 53 The 54 .Fn grapheme_to_${CASE}${SUFFIX} 55 function returns the number of ${UNIT}s in the array resulting 56 from converting 57 .Va src 58 to ${CASE}, even if 59 .Va destlen 60 is not large enough or 61 .Va dest 62 is 63 .Dv NULL . 64 .Sh SEE ALSO 65 .Xr grapheme_to_${CASE}${ANTISUFFIX} 3 , 66 .Xr libgrapheme 7 67 .Sh STANDARDS 68 .Fn grapheme_to_${CASE}${SUFFIX} 69 is compliant with the Unicode ${UNICODE_VERSION} specification. 70 .Sh AUTHORS 71 .An Laslo Hunhold Aq Mt dev@frign.de 72 EOF