OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 class _Base64 { | 7 class _Base64 { |
8 static const List<String> _encodingTable = const [ | 8 static const List<String> _encodingTable = const [ |
9 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', | 9 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', |
10 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', | 10 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 for (int j = 0; j < 2; j++) { | 44 for (int j = 0; j < 2; j++) { |
45 int index = (value >> ((3 - j) * 6)) & ((1 << 6) - 1); | 45 int index = (value >> ((3 - j) * 6)) & ((1 << 6) - 1); |
46 characters.add(_encodingTable[index]); | 46 characters.add(_encodingTable[index]); |
47 } | 47 } |
48 characters.add("="); | 48 characters.add("="); |
49 characters.add("="); | 49 characters.add("="); |
50 } | 50 } |
51 StringBuffer output = new StringBuffer(); | 51 StringBuffer output = new StringBuffer(); |
52 for (i = 0; i < characters.length; i++) { | 52 for (i = 0; i < characters.length; i++) { |
53 if (i > 0 && i % 76 == 0) { | 53 if (i > 0 && i % 76 == 0) { |
54 output.add("\r\n"); | 54 output.write("\r\n"); |
55 } | 55 } |
56 output.add(characters[i]); | 56 output.write(characters[i]); |
57 } | 57 } |
58 return output.toString(); | 58 return output.toString(); |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 /** | 62 /** |
63 * Base64 transfer decoding for MIME (RFC 2045). | 63 * Base64 transfer decoding for MIME (RFC 2045). |
64 */ | 64 */ |
65 static List<int> _decode(String data) { | 65 static List<int> _decode(String data) { |
66 List<int> result = new List<int>(); | 66 List<int> result = new List<int>(); |
(...skipping 30 matching lines...) Expand all Loading... |
97 if (padCount == 0) { | 97 if (padCount == 0) { |
98 result.add(value & 0xFF); | 98 result.add(value & 0xFF); |
99 } | 99 } |
100 charCount = 0; | 100 charCount = 0; |
101 value = 0; | 101 value = 0; |
102 } | 102 } |
103 } | 103 } |
104 return result; | 104 return result; |
105 } | 105 } |
106 } | 106 } |
OLD | NEW |