blob: 3db78b8f2ef5b4cf7d03dc3d6c4d55242c3f0b62 [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.
* @assertion ByteConversionSink asUtf8Sink(bool allowMalformed)
* Returns this as a sink that accepts UTF-8 input.
* If used, this method must be the first and only call to this. It invalidates
* this. All further operations must be performed on the result.
* @description Checks that this method returns this as a ByteConversionSink.
* Test allowMalformed == true
* @author
import "dart:convert";
import "../../../Utils/expect.dart";
main() {
bool called = false;
var outSink = new ByteConversionSink.withCallback((accumulated) {
called = true;
Expect.listEquals(utf8.encode("1�"), accumulated);
StringConversionSink inSink = utf8.encoder.startChunkedConversion(outSink);
ByteConversionSink bcs = inSink.asUtf8Sink(true);
bcs.add([0x80]); // Not valid UTF-8 character