[go: up one dir, main page]

1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/fml/base32.h"
6
7#include <string>
8
9namespace fml {
10
11static constexpr char kEncoding[] = "0123456789abcdef";
12
13std::string HexEncode(std::string_view input) {
14 std::string result;
15 result.reserve(requested_capacity: input.size() * 2);
16 for (char c : input) {
17 uint8_t b = static_cast<uint8_t>(c);
18 result.push_back(c: kEncoding[b >> 4]);
19 result.push_back(c: kEncoding[b & 0xF]);
20 }
21 return result;
22}
23
24} // namespace fml
25

source code of flutter_engine/flutter/fml/hex_codec.cc