Fix encoding of non-ascii contents written to parameter files. .

When args are written to parameter files, non-ascii values are wrongly encoded again as utf-8. This seems to be unaffected by the JDK20 upgrade of Bazel, and has always been happening.

Fixes #18792.

Closes #18972.

RELNOTES: Fixes non-ascii arguments written to parameter files as mojibake.
PiperOrigin-RevId: 549950259
Change-Id: Ia4997cdc049d1fcda266d63920b68afbed3f9ae1
diff --git a/src/test/shell/integration/unicode_test.sh b/src/test/shell/integration/unicode_test.sh
index 7ef3a33..d4108c8 100755
--- a/src/test/shell/integration/unicode_test.sh
+++ b/src/test/shell/integration/unicode_test.sh
@@ -72,4 +72,25 @@
     >>"${TEST_log}" 2>&1 || fail "Output not as expected"
 }
 
+function test_unicode_action_run_param_file {
+  local test_name="action_run_param_file"
+  bazel build --genrule_strategy=local --spawn_strategy=local \
+      "//:${test_name}" >& "$TEST_log" \
+      || fail "expected build to succeed"
+
+  quoted_unicode_test_expected="'$(cat unicode_test_expected.txt)'"
+
+  echo "Expected: ${quoted_unicode_test_expected}"
+
+  cat_output=$(cat "${PRODUCT_NAME}-bin/${test_name}.out")
+  assert_equals "${cat_output}" \
+      "${quoted_unicode_test_expected}" \
+      || fail "Output not as expected"
+
+  param_file_output=$(cat "${PRODUCT_NAME}-bin/${test_name}.out-0.params")
+  assert_equals "${param_file_output}" \
+        "${quoted_unicode_test_expected}" \
+        || fail "Output not as expected"
+}
+
 run_suite "Integration tests for ${PRODUCT_NAME}'s unicode i/o in actions"
\ No newline at end of file