コピペ: "[映]"などの文字列をARIB外字に変換するJavaのコード(文字コードはUnicode)

形式
Java
投稿日時
2017-10-30 00:40
公開期間
無期限
  1. /*
  2. * ARIB外字のマッピング情報
  3. */
  4. enum AribCharMap {
  5. HDTV ("HV" ,"\uE0F8"),
  6. SDTV ("SD" ,"\uE0F9"),
  7. PROGRESSIVE ("P" ,"\uE0FA"),
  8. WIDE ("W" ,"\uE0FB"),
  9. MULTIVIEW ("MV" ,"\uE0FC"),
  10. SIGN ("手" ,"\uE0FD"),
  11. SUBTITLE ("字" ,"\uE0FE"),
  12. TWOWAY ("双" ,"\uE0FF"),
  13. DATA ("デ" ,"\uE180"),
  14. STEREO ("S" ,"\uE181"),
  15. BILINGUAL ("二" ,"\uE182"),
  16. MULTIPLEX ("多" ,"\uE183"),
  17. COMMENTARY ("解" ,"\uE184"),
  18. SURROUND ("SS" ,"\uE185"),
  19. BMODE ("B" ,"\uE186"),
  20. NEWS ("N" ,"\uE187"),
  21. WEATHER ("天" ,"\uE18A"),
  22. TRAFFIC ("交" ,"\uE18B"),
  23. MOVIE ("映" ,"\uE18C"),
  24. FREE ("無" ,"\uE18D"),
  25. PAY ("料" ,"\uE18E"),
  26. FORMER ("前" ,"\uE190"),
  27. LATTER ("後" ,"\uE191"),
  28. REAIR ("再" ,"\uE192"),
  29. NEW ("新" ,"\uE193"),
  30. FIRST ("初" ,"\uE194"),
  31. END ("終" ,"\uE195"),
  32. LIVE ("生" ,"\uE196"),
  33. SHOPPING ("販" ,"\uE197"),
  34. VOICE ("声" ,"\uE198"),
  35. DUBBED ("吹" ,"\uE199"),
  36. PPV ("PPV" ,"\uE19A"),
  37. // SECRET ("秘" ,"\uE19B"),
  38. // OTHER ("ほか" ,"\uE19C"),
  39. ;
  40. String noaribStr;
  41. String aribStr;
  42. private AribCharMap(String n, String a){
  43. noaribStr = n;
  44. aribStr = a;
  45. }
  46. public String getNoAribPattern(){
  47. return "\\[" + noaribStr + "\\]";
  48. }
  49. public String getNoAribStr(){
  50. return "[" + noaribStr + "]";
  51. }
  52. public String getAribStr(){
  53. return aribStr;
  54. }
  55. /*
  56. * ARIB外字を展開した文字列からARIB外字を含む文字列に変換する
  57. */
  58. static String ConvStringToArib(String s){
  59. if (s == null)
  60. return s;
  61. for (AribCharMap acm : AribCharMap.values()){
  62. Matcher ma = Pattern.compile(acm.getNoAribPattern()).matcher(s);
  63. if (ma.find()){
  64. s = ma.replaceAll(acm.getAribStr());
  65. }
  66. }
  67. return s;
  68. }
  69. /*
  70. * ARIB外字を含む文字列から展開した文字列に変換する
  71. */
  72. static String ConvStringFromArib(String s){
  73. if (s == null)
  74. return s;
  75. for (AribCharMap acm : AribCharMap.values()){
  76. Matcher ma = Pattern.compile(acm.getAribStr()).matcher(s);
  77. if (ma.find()){
  78. s = ma.replaceAll(acm.getNoAribStr());
  79. }
  80. }
  81. return s;
  82. }
  83. };
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト