OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_ |
| 6 #define DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/strings/string_piece.h" |
| 12 |
| 13 namespace device { |
| 14 |
| 15 // The following functions EncodeUriBeaconUri() and DecodeUriBeaconUri() helps |
| 16 // encoding/decoding URI with the UriBeacon encoding. |
| 17 // |
| 18 // Example usage: |
| 19 // |
| 20 // std::vector<uint8_t> encoded; |
| 21 // EncodeUriBeaconUri("http://web.mit.edu/", encoded) |
| 22 // // encoded -> {2, 'w', 'e', 'b', '.', 'm', 'i', 't', 2} |
| 23 // |
| 24 // const char encodedUri[] = {0, 'u', 'r', 'i', 'b', 'e', 'a', 'c', 'o', 'n', |
| 25 // 8}; |
| 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" |
| 31 |
| 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); |
| 35 |
| 36 // Decodes the input string using URI encoding described in UriBeacon |
| 37 // specifications. |
| 38 void DecodeUriBeaconUri(const std::vector<uint8_t>& input, std::string& output); |
| 39 |
| 40 } // namespace device |
| 41 |
| 42 #endif |
OLD | NEW |