MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_utf8_emit_len

Function xo_utf8_emit_len

tools/libxo/libxo/libxo.c:1126–1143  ·  view source on GitHub ↗

* Determine the number of bytes needed to encode a wide character. */

Source from the content-addressed store, hash-verified

1124 * Determine the number of bytes needed to encode a wide character.
1125 */
1126static ssize_t
1127xo_utf8_emit_len (wchar_t wc)
1128{
1129 ssize_t len;
1130
1131 if ((wc & ((1 << 7) - 1)) == wc) /* Simple case */
1132 len = 1;
1133 else if ((wc & ((1 << 11) - 1)) == wc)
1134 len = 2;
1135 else if ((wc & ((1 << 16) - 1)) == wc)
1136 len = 3;
1137 else if ((wc & ((1 << 21) - 1)) == wc)
1138 len = 4;
1139 else
1140 len = -1; /* Invalid */
1141
1142 return len;
1143}
1144
1145/*
1146 * Emit one wide character into the given buffer

Callers 1

xo_format_string_directFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected