Repository: flutter
Issue: [Windows] Clipboard.setData stops copy once malformed character appears in the String
Labels: in triage

```dart
import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Future<void> main() async {
  runApp(const MyApp());

  final Uint8List readFile =
      await File(r'C:\Windows\System32\vcruntime140_1.dll').readAsBytes();

  final String tryUtf8 = utf8.decode(readFile, allowMalformed: true);
  print('UTF8 File as String: $tryUtf8');

  final String charcodes = String.fromCharCodes(readFile);
  print('Charcodes File as String: $tryUtf8');

  await Clipboard.setData(ClipboardData(text: tryUtf8));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
```

File content that we read with utf8

<img width="1728" alt="Image" src="https://github.com/user-attachments/assets/76d45f5b-5101-4e10-930b-a479a3989daa" />

What is copied to clipboard

<img width="795" alt="Image" src="https://github.com/user-attachments/assets/00cd45f9-d66e-4a58-9c92-4e08b9a370f5" />

File content that we read with charcodes

<img width="1702" alt="Image" src="https://github.com/user-attachments/assets/64072b24-8860-4c68-9da2-3b82f561a74f" />

What is copied to clipboard

<img width="831" alt="Image" src="https://github.com/user-attachments/assets/0f17f1f7-2297-4184-8272-ab4eff15b8e3" />


Flutter doctor -v

```dart
PS C:\Users\swiftsoft\Desktop\test_project> flutter doctor -v
[√] Flutter (Channel stable, 3.27.3, on Microsoft Windows [Version 10.0.26100.2605], locale en-US)
    • Flutter version 3.27.3 on channel stable at c:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c519ee916e (5 days ago), 2025-01-21 10:32:23 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[√] Windows Version (Installed version of Windows is version 10 or higher)

[X] Android toolchain - develop for Android devices
    • Android SDK at C:\Users\swiftsoft\AppData\Local\Android\sdk
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.

[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.11.35327.3
    • Windows 10 SDK version 10.0.22621.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).

[√] IntelliJ IDEA Community Edition (version 2024.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.2.4
    • Flutter plugin version 83.0.4
    • Dart plugin version 243.23177

[√] Connected device (2 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.2605]
    • Edge (web
```