java - 为什么我可以使用 US Ascii Locale 来处理大写/小写的德语变音符号?

标签 java ascii locale

建议如下代码:

package org.apache.creadur.rat2.core.ds;

import java.util.Locale;

public class TestUsAsciiLocale {
    public static void main(String[] pArgs) throws Exception {
        final String capitalLetterAe = "\u00c4";
        final String smallLetterAe = "\u00e4";
        if (capitalLetterAe.toLowerCase(Locale.GERMANY).equals(smallLetterAe)) {
            System.out.println("Capital Ae, and small ae are the same (case insensitive) in the german Locale.");
        }
        if (capitalLetterAe.toLowerCase(Locale.US).equals(smallLetterAe)) {
            System.out.println("Capital Ae, and small ae are the same (case insensitive) in the US Locale.");
        }
    }
}

输出如下:

Capital Ae, and small ae are the same (case insensitive) in the german Locale.
Capital Ae, and small ae are the same (case insensitive) in the US Locale.

我觉得这很奇怪。我希望美国 Ascii 语言环境能够准确对待 [a-zA-Z] 可大写/小写。

谢谢,

乔臣

最佳答案

您的代码中存在错误:

    if (capitalLetterAe.toLowerCase(Locale.GERMANY).equals(smallLetterAe)) {
        System.out.println("Capital Ae, and small ae are the " +
             "same (case insensitive) in the US Locale.");
    }

您正在使用 Locale.GERMANY,但消息显示“在美国区域设置”。

关于java - 为什么我可以使用 US Ascii Locale 来处理大写/小写的德语变音符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37722202/

相关文章:

arrays - 根据空行或任何未使用的字符将文本文件拆分为数组

bash - 将 ASCII 中的 Char 值保存在 bash 变量中

java - Spring MVC 测试中没有定义 [javax.persistence.EntityManagerFactory] ​​类型的合格 bean 问题

java - 我需要在 JDA 中使用什么方法来检查消息是否包含图像?

email - 为什么 “-”(连字符)是电子邮件兼容性的唯一 ASCII 限制?

javascript - 如何在 Js 中删除 toLocaleString() 上的日期和时间之间的逗号

java - 没有获取特定语言环境的货币符号

java - Apache POI - Docx 输出问题

java - 在 OpenGL (lwjgl) 中查看网格

java - 在 JPanel 上显示 JFreeChart 的缩略图