1 // Copyright 2015 The Chromium 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.
5 #ifndef DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_
6 #define DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_
11 #include "base/strings/string_piece.h"
15 // The following functions EncodeUriBeaconUri() and DecodeUriBeaconUri() helps
16 // encoding/decoding URI with the UriBeacon encoding.
20 // std::vector<uint8_t> encoded;
21 // EncodeUriBeaconUri("http://web.mit.edu/", encoded)
22 // // encoded -> {2, 'w', 'e', 'b', '.', 'm', 'i', 't', 2}
24 // const char encodedUri[] = {0, 'u', 'r', 'i', 'b', 'e', 'a', 'c', 'o', 'n',
26 // const std::vector<uint8_t> kEncodedUri(encodedUri, encodedUri +
27 // sizeof(encodedUri));
28 // std::string decoded;
29 // DecodeUriBeaconUri(kEncodedUri, decoded)
30 // // decoded -> "http://uribeacon.org"
32 // Encodes the input string using URI encoding described in UriBeacon
33 // specifications. |input| must be ASCII characters.
34 void EncodeUriBeaconUri(const std::string
& input
, std::vector
<uint8_t>& output
);
36 // Decodes the input string using URI encoding described in UriBeacon
38 void DecodeUriBeaconUri(const std::vector
<uint8_t>& input
, std::string
& output
);