Repository: flutter
Issue: [web]: Unicode char throws `Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER)` error
Labels: c: crash,tool,platform-web,has reproducible steps,P2,team-tool,triaged-tool,found in release: 3.13,found in release: 3.16

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

I have searched that there were similar issues but they are closed without any fix. I suppose that error in Flutter debug console in Android Studio or something related with this. I suppose so because there's no any issues with rendering such special characters but only if there appears in console (you can see this in attached video)

Second, I think the problem is wrong conversion from special char (in my case **�**) to bytes (`[239, 191, 189, 10]` but it must be `[239, 191, 189]`).

There's no any problems in release mode or if I go to `localhost` from other browser instance which is not connected to Flutter debugger. But using other instance of browser is not a solution because it makes development very difficult in such circumstances))

To reproduce just start my example code

### Expected results

Flutter debugger shows **�** in console

### Actual results

App crashes

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {

    const String crashString = "�";

    return MaterialApp(
      title: 'App crasher',
      home: Center(
        child: TextButton(onPressed: () => print(crashString), child: const Text("Crash app")),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

https://github.com/flutter/flutter/assets/76728763/cd66f344-1dc1-4785-b40a-f14f9cee0206

</details>


### Logs

<details><summary>Logs</summary>

```console
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:54270/2-5SauS8BYM=/ws
Debug service listening on ws://127.0.0.1:54270/2-5SauS8BYM=/ws
Debug service listening on ws://127.0.0.1:54270/2-5SauS8BYM=/ws
Finished with error: Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER) found while decoding string: �
. The Flutter team would greatly appreciate if you could file a bug explaining exactly what you were doing when this happened:
https://github.com/flutter/flutter/issues/new/choose
The source bytes were:
[239, 191, 189, 10]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.13.8, on macOS 14.0 23A344 darwin-arm64, locale ru-BY)
    • Flutter version 3.13.8 on channel stable at /Users/admin/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6c4930c4ac (3 days ago), 2023-10-18 10:57:55 -0500
    • Engine revision 767d8c75e8
    • Dart version 3.1.4
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/admin/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Users/admin/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Users/admin/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] Connected device (3 available)
    • iPhone (mobile) • 00008030-00125C940292802E • ios            • iOS 17.0.3 21A360
    • macOS (desktop) • macos                     • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)    • chrome                    • web-javascript • Google Chrome 118.0.5993.96

[✓] Network resources
    • All expected network resources are available.

• No issues found!

```

</details>