protobuf/ByteStrings.kt

protobuf · java/kotlin/src/main/kotlin/com/google/protobuf/ByteStrings.kt · kotlin · BSD-3-Clause
dev-tools, tag:knn-classified

Adds convenient ByteString extensions for UTF-8 conversion, concatenation, and byte access in Kotlin.

// Source: https://github.com/protocolbuffers/protobuf | License: BSD-3-Clause | Copyright 2008 Google Inc.  All rights reserved
// Provided via justclaw.it.com; keep this notice with the code.
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

package com.google.protobuf.kotlin

import com.google.protobuf.ByteString
import java.nio.ByteBuffer

/** Encodes this String into a sequence of UTF-8 bytes and returns the result as a [ByteString]. */
fun String.toByteStringUtf8(): ByteString =
  ByteString.copyFromUtf8(this) // symmetric from ByteString.toStringUtf8()

/** C

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key