Java Gitlab 上的字符编码差异

Java character encoding discrepancies on Gitlab

我看到我的代码 运行 在本地生成的字符不同于它在 Gitlab 暂存管道中 运行 时触发相关测试失败的行为。具体来说,

这是我在本地环境中看到的输出:

这是分期的:

看起来暂存盒上的测试以某种方式误解了 $ 格式,并且 $ 字符被替换为 ¤

这是相关的 Java 代码,我正在获取默认语言环境来制定消息:

return new String[] { headerLine.toString(),
                "Date: " + tx.getTransactionDate().getDate().toString() + "\nAmount: "

                        + NumberFormat.getCurrencyInstance(Locale.getDefault()).format(tx.getAmount()) + "\nAccount: "
                        + (accumulatedInputs.get(FIELD_ACTNUM) != null
                                ? accumulatedInputs.get(FIELD_ACTNUM).value
                                : accumulatedInputs.get(TransactionInquiryIntentProcessor.FIELD_REFNUM).value)
                        + "\n" + subTitleBuilder.toString() };

不确定在该暂存环境中可能出现什么问题?

我们最终让 DevOps 团队在 Kubernetes 中明确指定 en_US 语言环境,这解决了这个问题。