2015/07/31

Java - String.format("%d", i)で数字が出てくると思ってたら死んだ話 - Qiita
http://qiita.com/tnj/items/022b906ac5435a429369

数字がロケール文字になったり、toLowerCase() や toUpperCase() の結果がロケール文字になったりするだけじゃないんだぜ。

import java.util.Locale;

public class Foo {
    public static void main(String[] args) {
        Locale.setDefault(new Locale("pt""BR"));
        String csv = String.format("%s,%f""hello"1.23);
        System.out.println(csv);
    }
}

とあるヨーロッパ南米のロケールではこの結果がこうなる。

hello,1,230000
( ゚д゚) 

(つд⊂)ゴシゴシ 
  
(;゚д゚) 
hello,1,230000
(つд⊂)ゴシゴシ 
  _, ._ 
(;゚ Д゚) …?! 
hello,1,230000   _, ._ 
(つд⊂)ゴシゴシゴシゴシゴシゴシゴシゴシ 

(  д ) 
      
(; Д ) ! 


(; Д )カオカオカオカオ 
 U_, ._U 
  ゚  ゚ 
  _, ._ 
(つд⊂)ゴシゴシゴシゴシゴシゴシゴシゴシ 

  _, ._ 
(;゚ Д゚) 

結論 ポルトガル語怖い。

参考資料

幾らかのヨーロッパロケールで小数点が機能しない · Issue #172 · vim-jp/issues · GitHub
https://github.com/vim-jp/issues/issues/172
Posted at 17:58 | WriteBacks () | Edit
Edit this entry...

wikieditish message: Ready to edit this entry.






















A quick preview will be rendered here when you click "Preview" button.