OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Utilities for plugins for the cromo modem manager. | 5 // Utilities for plugins for the cromo modem manager. |
6 | 6 |
7 #ifndef CROMO_UTILITIES_H_ | 7 #ifndef CROMO_UTILITIES_H_ |
8 #define CROMO_UTILITIES_H_ | 8 #define CROMO_UTILITIES_H_ |
9 | 9 |
10 #include <base/basictypes.h> | 10 #include <base/basictypes.h> |
11 #include <map> | 11 #include <map> |
(...skipping 29 matching lines...) Expand all Loading... |
41 | 41 |
42 // Convert a string representing a hex ESN to one representing a | 42 // Convert a string representing a hex ESN to one representing a |
43 // decimal ESN. Returns success. | 43 // decimal ESN. Returns success. |
44 bool HexEsnToDecimal(const std::string& esn_hex, std::string* out); | 44 bool HexEsnToDecimal(const std::string& esn_hex, std::string* out); |
45 | 45 |
46 // Converts an array of bytes containing text encoded in the GSM 03.38 | 46 // Converts an array of bytes containing text encoded in the GSM 03.38 |
47 // character set (also know as GSM-7) into a UTF-8 encoded string. | 47 // character set (also know as GSM-7) into a UTF-8 encoded string. |
48 // GSM-7 is a 7-bit character set, and in SMS messages, the 7-bit | 48 // GSM-7 is a 7-bit character set, and in SMS messages, the 7-bit |
49 // septets are packed into an array of 8-bit octets. | 49 // septets are packed into an array of 8-bit octets. |
50 // | 50 // |
51 // The first byte of the input array the length of the converted | 51 // The first byte of the input array gives the length of the converted |
52 // data in septets, i.e., it is the number of GSM-7 septets that | 52 // data in septets, i.e., it is the number of GSM-7 septets that |
53 // will result after the array is unpacked. | 53 // will result after the array is unpacked. |
54 std::string Gsm7ToUtf8String(const uint8_t* gsm7); | 54 std::string Gsm7ToUtf8String(const uint8_t* gsm7); |
55 | 55 |
56 // Converts a string of characters encoded using UTF-8 into an | 56 // Converts a string of characters encoded using UTF-8 into an |
57 // array of bytes which is result of converting the string into | 57 // array of bytes which is result of converting the string into |
58 // septets in the GSM-7 alphabet and then packing the septets into | 58 // septets in the GSM-7 alphabet and then packing the septets into |
59 // octets. | 59 // octets. |
60 std::vector<uint8_t> Utf8StringToGsm7(const std::string& input); | 60 std::vector<uint8_t> Utf8StringToGsm7(const std::string& input); |
61 | 61 |
| 62 // Converts an array of bytes containing text in the UCS-2 encoding |
| 63 // into a UTF-8 encoded string. |
| 64 // |
| 65 // The first byte of the input array gives the length of the converted |
| 66 // data in octets. Dividing this number by 2 gives the number of |
| 67 // characters in the text. |
| 68 std::string Ucs2ToUtf8String(const uint8_t* ucs2); |
| 69 |
| 70 // Convert a UTF-8 encoded string to a byte array encoding |
| 71 // the string as UCS-2. |
| 72 std::vector<uint8_t> Utf8StringToUcs2(const std::string& input); |
| 73 |
62 // Debugging utility for printing an array of bytes in a nicely | 74 // Debugging utility for printing an array of bytes in a nicely |
63 // formatted manner á la the UNIX hd command. | 75 // formatted manner á la the UNIX hd command. |
64 void DumpHex(const uint8_t* buf, size_t size); | 76 void DumpHex(const uint8_t* buf, size_t size); |
65 | 77 |
66 } // namespace utilities | 78 } // namespace utilities |
67 | 79 |
68 #endif /* CROMO_UTILITIES_H_ */ | 80 #endif /* CROMO_UTILITIES_H_ */ |
OLD | NEW |