Change return type of decodeBase64 to Uint8List.

Matches base64.decode.

Change-Id: Ida4e2a450940217959089d5bc48b6462b52df755
Reviewed-on: https://dart-review.googlesource.com/46140
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
Lasse Reichstein Holst Nielsen 2018-03-13 08:12:52 +00:00 committed by commit-bot@chromium.org
parent dc67800cb8
commit 0b5d718489
5 changed files with 21 additions and 12 deletions

View file

@ -5,9 +5,12 @@
* Temporarily disabled the `whereType` method until generic methods are
enabled on all platforms
([issue 32463](https://github.com/dart-lang/sdk/issues/32463)).
* Changed return type of `UriData.dataAsBytes` to `Uint8List`.
* `dart:convert`
* Added `jsonEncode`, `jsonDecode`, `base64Encode`, `base64UrlEncode` and
`base64Decode` top-level functions.
* Changed return type of `encode` on `AsciiCodec` and `Latin1Codec`,
and `convert` on `AsciiEncoder`, `Latin1Encoder`, to `Uint8List`.
## 2.0.0

View file

@ -11,10 +11,11 @@ part of dart.convert;
* use cases.
*
* Examples:
*
* var encoded = ascii.encode("This is ASCII!");
* var decoded = ascii.decode([0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
* 0x20, 0x41, 0x53, 0x43, 0x49, 0x49, 0x21]);
* ```dart
* var encoded = ascii.encode("This is ASCII!");
* var decoded = ascii.decode([0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
* 0x20, 0x41, 0x53, 0x43, 0x49, 0x49, 0x21]);
* ```
*/
const AsciiCodec ascii = const AsciiCodec();
@Deprecated("Use ascii instead")
@ -43,6 +44,8 @@ class AsciiCodec extends Encoding {
String get name => "us-ascii";
Uint8List encode(String source) => encoder.convert(source);
/**
* Decodes the ASCII [bytes] (a list of unsigned 7-bit integers) to the
* corresponding string.
@ -82,12 +85,12 @@ class _UnicodeSubsetEncoder extends Converter<String, List<int>> {
* If [start] and [end] are provided, only the substring
* `string.substring(start, end)` is used as input to the conversion.
*/
List<int> convert(String string, [int start = 0, int end]) {
Uint8List convert(String string, [int start = 0, int end]) {
int stringLength = string.length;
RangeError.checkValidRange(start, end, stringLength);
if (end == null) end = stringLength;
int length = end - start;
List<int> result = new Uint8List(length);
var result = new Uint8List(length);
for (int i = 0; i < length; i++) {
var codeUnit = string.codeUnitAt(start + i);
if ((codeUnit & ~_subsetMask) != 0) {

View file

@ -57,7 +57,7 @@ String base64UrlEncode(List<int> bytes) => base64Url.encode(bytes);
*
* Shorthand for [base64.decode].
*/
List<int> base64Decode(String source) => base64.decode(source);
Uint8List base64Decode(String source) => base64.decode(source);
// Constants used in more than one class.
const int _paddingChar = 0x3d; // '='.

View file

@ -11,10 +11,11 @@ part of dart.convert;
* use cases.
*
* Examples:
*
* var encoded = latin1.encode("blåbærgrød");
* var decoded = latin1.decode([0x62, 0x6c, 0xe5, 0x62, 0xe6,
* 0x72, 0x67, 0x72, 0xf8, 0x64]);
* ```dart
* var encoded = latin1.encode("blåbærgrød");
* var decoded = latin1.decode([0x62, 0x6c, 0xe5, 0x62, 0xe6,
* 0x72, 0x67, 0x72, 0xf8, 0x64]);
* ```
*/
const Latin1Codec latin1 = const Latin1Codec();
@Deprecated("Use latin1 instead")
@ -42,6 +43,8 @@ class Latin1Codec extends Encoding {
String get name => "iso-8859-1";
Uint8List encode(String source) => encoder.convert(source);
/**
* Decodes the Latin-1 [bytes] (a list of unsigned 8-bit integers) to the
* corresponding string.

View file

@ -3472,7 +3472,7 @@ class UriData {
* percent-escaped characters and returning byte values of each unescaped
* character. The bytes will not be, e.g., UTF-8 decoded.
*/
List<int> contentAsBytes() {
Uint8List contentAsBytes() {
String text = _text;
int start = _separatorIndices.last + 1;
if (isBase64) {