12namespace entropic::mcp {
38 if (
b < 0x80) {
n = 0; }
39 else if (
b >= 0xC2 &&
b < 0xE0) {
n = 1; }
40 else if (
b >= 0xE0 &&
b < 0xF0) {
n = 2; }
41 else if (
b >= 0xF0 &&
b < 0xF5) {
n = 3; }
61 else if (
lead == 0xED) {
ok =
ok &&
c1 <= 0x9F; }
62 else if (
lead == 0xF0) {
ok =
ok &&
c1 >= 0x90; }
63 else if (
lead == 0xF4) {
ok =
ok &&
c1 <= 0x8F; }
81 for (
int i = 2;
ok &&
i <=
n; ++
i) {
84 return ok ?
static_cast<size_t>(
n + 1) : 0;
105 out.reserve(
input.size());
106 const auto*
p =
reinterpret_cast<const uint8_t*
>(
input.data());
111 out.append(
reinterpret_cast<const char*
>(
p),
len);
@ ok
Tool dispatched, returned non-empty content.
@ optional
optional: every escape asks the host's path approver
UTF-8 validation + replacement at every system boundary where bytes change ownership.
ENTROPIC_EXPORT std::string sanitize_utf8(std::string_view input)
Replace invalid UTF-8 byte sequences with U+FFFD.