Repository navigation
[web]: Unicode char throws Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER) error #137025
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
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
Code sample
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")),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
37484d2d-7302-406a-87f3-f8b81dbd843b.mp4
Logs
Logs
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]Flutter Doctor output
Doctor output
[✓] 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!
Activity
d-polikhranidi commentedon Oct 22, 2023
Aha, I found from where this error rises: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/convert.dart#L60
I believe that � not indicates malformed input.
LucyJeong commentedon Oct 22, 2023
@d-polikhranidi How to fix it? just remove � char?? or handling � char??
d-polikhranidi commentedon Oct 22, 2023
if you experiencing problems only in
printfunction (output inside your console) just useloginstead ofprintdarshankawar commentedon Oct 23, 2023
Thanks for the report. I see that the reported error occurs only on web, as it works as expected on mobile and desktop.
stable, master flutter doctor -v
[-][web, maybe all platfroms / flutter debugger] Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER)[/-][+][web]: Unicode char throws `Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER)` error[/+]9 remaining items
ditman commentedon Nov 2, 2023
The exception comes from here:
flutter/packages/flutter_tools/lib/src/convert.dart
Lines 56 to 69 in 92ea5e0
It seems the flutter tool has its own Utf8 codec that may be configured to log this error or not, right before throwing (I wonder if it can be configured to remove these weird characters, or replace them by a tofu box □ instead, so the app can continue)
Other reports:
(Some similar reports come from vscode info being written to the log, but that seems to have been fixed by adding the initial configurability to the codec, see git blame for
reportErrors)nvbien2000 commentedon Apr 9, 2024
grobarko commentedon Jul 30, 2024
andrewkolos commentedon Jul 30, 2024
Per https://github.com/flutter/flutter/blob/master/docs/contributing/issue_hygiene/README.md#when-will-my-bug-be-fixed, please don't ask for updates. Such comments ultimately slow down work on the project. Instead, consider adding a +1 reaction on the top level comment.
Any updates will be posted as they are available, or the issue will have an assignee if it's being worked on. As always, anyone is welcome to submit their own pull request to resolve the issue.
x544D commentedon Nov 30, 2024
github-actions commentedon Jul 28, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.