| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // and returns a StringPiece that points to this buffer. The input buffer needs | 248 // and returns a StringPiece that points to this buffer. The input buffer needs |
| 249 // to be at least 6 bytes long. | 249 // to be at least 6 bytes long. |
| 250 StringPiece ToHex(uint16 cp, char* buffer) { | 250 StringPiece ToHex(uint16 cp, char* buffer) { |
| 251 buffer[5] = kHex[cp & 0x0f]; | 251 buffer[5] = kHex[cp & 0x0f]; |
| 252 cp >>= 4; | 252 cp >>= 4; |
| 253 buffer[4] = kHex[cp & 0x0f]; | 253 buffer[4] = kHex[cp & 0x0f]; |
| 254 cp >>= 4; | 254 cp >>= 4; |
| 255 buffer[3] = kHex[cp & 0x0f]; | 255 buffer[3] = kHex[cp & 0x0f]; |
| 256 cp >>= 4; | 256 cp >>= 4; |
| 257 buffer[2] = kHex[cp & 0x0f]; | 257 buffer[2] = kHex[cp & 0x0f]; |
| 258 return StringPiece(buffer).substr(0, 6); | 258 return StringPiece(buffer, 0, 6); |
| 259 } | 259 } |
| 260 | 260 |
| 261 // Stores the 32-bit unicode code point as its hexadecimal digits in buffer | 261 // Stores the 32-bit unicode code point as its hexadecimal digits in buffer |
| 262 // and returns a StringPiece that points to this buffer. The input buffer needs | 262 // and returns a StringPiece that points to this buffer. The input buffer needs |
| 263 // to be at least 12 bytes long. | 263 // to be at least 12 bytes long. |
| 264 StringPiece ToSurrogateHex(uint32 cp, char* buffer) { | 264 StringPiece ToSurrogateHex(uint32 cp, char* buffer) { |
| 265 uint16 low = ToLowSurrogate(cp); | 265 uint16 low = ToLowSurrogate(cp); |
| 266 uint16 high = ToHighSurrogate(cp); | 266 uint16 high = ToHighSurrogate(cp); |
| 267 | 267 |
| 268 buffer[11] = kHex[low & 0x0f]; | 268 buffer[11] = kHex[low & 0x0f]; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 if (num_left > 0) { | 395 if (num_left > 0) { |
| 396 // Treat as case iii: report error. | 396 // Treat as case iii: report error. |
| 397 // TODO(wpoon): Add error reporting. | 397 // TODO(wpoon): Add error reporting. |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace converter | 401 } // namespace converter |
| 402 } // namespace util | 402 } // namespace util |
| 403 } // namespace protobuf | 403 } // namespace protobuf |
| 404 } // namespace google | 404 } // namespace google |
| OLD | NEW |