flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.21k stars 26.64k forks source link

Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER) found while decoding string #147509

Closed Dohun-choi closed 2 weeks ago

Dohun-choi commented 2 weeks ago

Steps to reproduce

I send a HTTP request to https://cataas.com/cat and i print request and response by using dio package.

image [239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189, 0, 67, 0, 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10]

i really don't no about this issue...

Expected results

just print...

Actual results

image

Code sample

Code sample ```dart import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; final api = Dio( BaseOptions( baseUrl: dotenv.get('BASE_URL'), ), ); final interceptors = InterceptorsWrapper( onRequest: (RequestOptions options, RequestInterceptorHandler handler) { debugPrint('REQUEST[${options.method}] => PATH: ${options.path}'); debugPrint("${options.data}"); return handler.next(options); }, onResponse: (Response response, ResponseInterceptorHandler handler) { debugPrint( 'RESPONSE[${response.statusCode}] => PATH: ${response.requestOptions.path}'); debugPrint("${response.data}"); return handler.next(response); }, onError: (DioException error, ErrorInterceptorHandler handler) { debugPrint( 'ERROR[${error.response?.statusCode}] => PATH: ${error.requestOptions.path}'); return handler.next(error); }, ); ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER) found while decoding string: ����C . 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, 239, 191, 189, 239, 191, 189, 239, 191, 189, 0, 67, 0, 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10] ```

Flutter Doctor output

Doctor output ```console $ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.19045.4291], locale ko-KR) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.5) [√] Android Studio (version 2023.2) [√] IntelliJ IDEA Community Edition (version 2023.3) [√] VS Code (version 1.85.1) [√] Connected device (3 available) [√] Network resources • No issues found! ```
Dohun-choi commented 2 weeks ago

Steps to reproduce

I send a HTTP request to https://cataas.com/cat and i print request and response by using dio package.

image [239, 191, 189, 239, 191, 189, 239, 191, 189, 239, 191, 189, 0, 67, 0, 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10]

i really don't no about this issue...

Expected results

just print...

Actual results

image

Code sample

Code sample

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';

final api = Dio(
  BaseOptions(
    baseUrl: dotenv.get('BASE_URL'),
  ),
);

final interceptors = InterceptorsWrapper(
  onRequest: (RequestOptions options, RequestInterceptorHandler handler) {
    debugPrint('REQUEST[${options.method}] => PATH: ${options.path}');
    debugPrint("${options.data}");
    return handler.next(options);
  },
  onResponse: (Response response, ResponseInterceptorHandler handler) {
    debugPrint(
        'RESPONSE[${response.statusCode}] => PATH: ${response.requestOptions.path}');
    debugPrint("${response.data}");
    return handler.next(response);
  },
  onError: (DioException error, ErrorInterceptorHandler handler) {
    debugPrint(
        'ERROR[${error.response?.statusCode}] => PATH: ${error.requestOptions.path}');
    return handler.next(error);
  },
);

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs

Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER) found while decoding string: ����C
. 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, 239, 191, 189, 239, 191, 189, 239, 191, 189, 0, 67, 0, 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10]   ```

</details>

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.19045.4291], locale ko-KR)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.5)
[√] Android Studio (version 2023.2)
[√] IntelliJ IDEA Community Edition (version 2023.3)
[√] VS Code (version 1.85.1)
[√] Connected device (3 available)
[√] Network resources

• No issues found!

I think i found reason.. ${response.data} was image file and it's length of toString() was too long to print...?

danagbemava-nc commented 2 weeks ago

Closing this as a duplicate of https://github.com/flutter/flutter/issues/137025

github-actions[bot] commented 3 days ago

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 -v and a minimal reproduction of the issue.