在Java中使用toUpperCase()将ß.cfg转换为大写 [英] converting ß.cfg to upper case using toUpperCase() in java

查看:47
本文介绍了在Java中使用toUpperCase()将ß.cfg转换为大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循代码

String s1 = "ß.cfg";
System.out.println (s.toUpperCase());

我得到的

输出为 SS.CFG ,因为Unicode并未定义ß的大写版本,而我希望输出为ß.CFG.

output I am getting is SS.CFG since Unicode didn't define an uppercase version of ß while I want the output as ß.CFG.

有什么办法可以实现?

推荐答案

The documentation for toUpperCase( Locale ) explicitly states that this is what will happen:

由于案例映射并不总是1:1字符映射,因此生成的String的长度可能与原始String的长度不同.

Since case mappings are not always 1:1 char mappings, the resulting String may be a different length than the original String.

小写字母s->两个字母:SS

small letter sharp s -> two letters: SS

这篇关于在Java中使用toUpperCase()将ß.cfg转换为大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆