这段代码在开发环境中运行良好,但在生产环境中运行良好。
import java.text.Normalizer;
public class TestNorm {
public static void main(String args[]) {
String s = "";
for (String s1: args) {
s = s + " " + s1;
}
System.out.println(Normalizer.normalize(s.toLowerCase(), Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "").replaceAll("[^\\p{Alnum}]+", "-").replaceAll("^[^a-z0-9]+", "").replaceAll("[^a-z0-9]+$", ""));
}
}
(空白的)
DevEnv$ java TestNorm hellö
> hello
(空白的)
ProdEnv$ java TestNorm hellö
> hell
我错过了什么?为什么我没有得到相同的 Normalizer 结果;“你好”?
可能是一个有用的信息
DevEnv$ java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
(空白的)
ProdEnv$ java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)