blob: e7da52f09734f3f938e7c40f670f3c912cdffe0b [file] [log] [blame]
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
/// @assertion String decode(List<int> codeUnits, {bool allowMalformed})
/// Decodes the UTF-8 codeUnits (a list of unsigned 8-bit integers) to the
/// corresponding string.
/// ...
/// If allowMalformed is not given, it defaults to the allowMalformed that was
/// used to instantiate this.
/// @description Checks that If allowMalformed is not given, it defaults to the
/// allowMalformed that was used to instantiate this.
/// @author sgrekhov@unipro.ru
import "dart:convert";
import "../../../Utils/expect.dart";
main() {
Utf8Codec codec = new Utf8Codec(allowMalformed: true);
Expect.equals("�", codec.decode([0xFE]));
codec = new Utf8Codec(allowMalformed: false);
Expect.throws(() {codec.decode([0xFE]);}, (e) => e is FormatException);
}