Skip to content

Commit

Permalink
use SystemEncoding to decode stdout and stderr in runProcess
Browse files Browse the repository at this point in the history
  • Loading branch information
rainyl committed Feb 17, 2025
1 parent 7cb1ef7 commit 71d5b7d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkgs/native_toolchain_c/lib/src/utils/run_process.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:logging/logging.dart';
Expand Down Expand Up @@ -46,7 +45,7 @@ Future<RunProcessResult> runProcess({

final stdoutSub = process.stdout.listen((List<int> data) {
try {
final decodedData = utf8.decode(data);
final decodedData = _systemEncoding.decode(data);
logger?.fine(decodedData);
stdoutBuffer.write(decodedData);
} catch (e) {
Expand All @@ -56,7 +55,7 @@ Future<RunProcessResult> runProcess({
});
final stderrSub = process.stderr.listen((List<int> data) {
try {
final decodedData = utf8.decode(data);
final decodedData = _systemEncoding.decode(data);
logger?.severe(decodedData);
stderrBuffer.write(decodedData);
} catch (e) {
Expand Down Expand Up @@ -116,3 +115,5 @@ exitCode: $exitCode
stdout: $stdout
stderr: $stderr''';
}

const _systemEncoding = SystemEncoding();

0 comments on commit 71d5b7d

Please sign in to comment.