OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> | 2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> |
3 Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> | 3 Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> |
4 Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 4 Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
5 Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 5 Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU Lesser General Public License (LGPL) | 8 it under the terms of the GNU Lesser General Public License (LGPL) |
9 version 2 as published by the Free Software Foundation. | 9 version 2 as published by the Free Software Foundation. |
10 | 10 |
11 This program is distributed in the hope that it will be useful, | 11 This program is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU Library General Public | 16 You should have received a copy of the GNU Library General Public |
17 License along with this program; if not, write to the Free Software | 17 License along with this program; if not, write to the Free Software |
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
19 USA. | 19 USA. |
20 | 20 |
21 This code is based on the java implementation in HTTPClient | 21 This code is based on the java implementation in HTTPClient |
22 package by Ronald Tschalaer Copyright (C) 1996-1999. | 22 package by Ronald Tschalaer Copyright (C) 1996-1999. |
23 */ | 23 */ |
24 | 24 |
25 #include "wtf/text/Base64.h" | 25 #include "wtf/text/Base64.h" |
26 | 26 |
| 27 #include <limits.h> |
27 #include "wtf/StringExtras.h" | 28 #include "wtf/StringExtras.h" |
28 #include <limits.h> | |
29 | 29 |
30 namespace WTF { | 30 namespace WTF { |
31 | 31 |
32 static const char base64EncMap[64] = { | 32 static const char base64EncMap[64] = { |
33 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, | 33 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, |
34 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, | 34 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, |
35 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, | 35 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, |
36 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, | 36 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, |
37 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, | 37 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, |
38 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F}; | 38 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F}; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 unsigned length, | 263 unsigned length, |
264 Base64EncodePolicy policy) { | 264 Base64EncodePolicy policy) { |
265 return base64Encode(data, length, policy).replace('+', '-').replace('/', '_'); | 265 return base64Encode(data, length, policy).replace('+', '-').replace('/', '_'); |
266 } | 266 } |
267 | 267 |
268 String normalizeToBase64(const String& encoding) { | 268 String normalizeToBase64(const String& encoding) { |
269 return String(encoding).replace('-', '+').replace('_', '/'); | 269 return String(encoding).replace('-', '+').replace('_', '/'); |
270 } | 270 } |
271 | 271 |
272 } // namespace WTF | 272 } // namespace WTF |
OLD | NEW |