blob: 5b3c8c5494fa9316756d3658be5c12f9e385502f [file] [log] [blame] [edit]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "fuchsia_web/common/string_util.h"
#include <string_view>
#include "base/compiler_specific.h"
std::vector<uint8_t> StringToBytes(std::string_view str) {
const uint8_t* raw_data = reinterpret_cast<const uint8_t*>(str.data());
return std::vector<uint8_t>(raw_data, UNSAFE_TODO(raw_data + str).length());
}
std::string_view BytesAsString(const std::vector<uint8_t>& bytes) {
return std::string_view(reinterpret_cast<const char*>(bytes.data()),
bytes.size());
}