SofaBuffers TypeScript - v0.11.0
    Preparing search index...

    Function decodeUtf8

    • Decode buf[start..end) as strict UTF-8 — the whole of buf when the range is omitted, which is the shape a reassembled payload (see PayloadAcc) arrives in.

      Malformed bytes throw a SofabError (INVALID_MSG), never the fatal TextDecoder's bare TypeError. The mapping belongs here rather than at each call site: invalid UTF-8 is an invalid message (MESSAGE_SPEC §8, CORELIB_PLAN §6.4), so it has to reach a caller as the same INVALID verdict as every other malformation — through the one catch (e) { if (e instanceof SofabError) … } a consumer writes — and a platform exception escaping that clause is precisely the bug this closes.

      A zero-length payload is the empty string, decoded without touching the platform decoder.

      Parameters

      • buf: Uint8Array
      • start: number = 0
      • end: number = buf.length

      Returns string