U+FFFF以ä¸ã®æåã£ã¦ãªãããâããµãã²ã¼ããã¢ã£ã¦ãªãããâãSpring Web Services ãè¨ããã¨ãèãã¾ããï¼ãã¨ãã§ä¸æ¥æ½°ãã話
表é¡ã®ãããªæããªã®ã§ãããããã¾ã§ç解ãææ§ã ã£ãUnicodeã¨ãä½ã¨ããä»ã¾ã§ããããã£ãã®ã§ã¡ã¢ã
å°ããã¡ãã®ãµã¤ããé常ã«åèã«ããã¦ããã ãã¾ããã
ã³ã¼ããã¤ã³ãã¨ã¯ãæåã³ã¼ãã¨ã¯
ä»æ¥è¦ããåèªãã®ä¸ãUnicodeã«éãããæåãã³ã³ãã¥ã¼ã¿ä¸ã§è¡¨ç¾ããéã1ã¤ã®æåã«1ã¤ã®æ°å¤ã対å¿ãããããã§ããããã®æåã«å¯¾å¿ããæ°å¤ãã³ã¼ããã¤ã³ãã¨ããããã
ãã¾ã¾ã§ASCIIã³ã¼ãã¨ãå¼ãã§ã¾ããã
ããã¦ãæåã¨æ°å¤ã®å²ãå½ã¦ã®ã«ã¼ã«ã®ãã¨ããæåã³ã¼ããã¨è¨ããã ããã§ãã
Unicodeã¨ã¯ããããUTF-XXã¯ä½ãéãããããã¨ãã話ã¸
Unicodeèªç
æåã³ã¼ããä¹±ç«ãããããããã³ã¼ããã¤ã³ãã§è¡¨ç¾ãããæåããæåã³ã¼ãã«ãã£ã¦ãã¦ãã§ã°ãã°ãã¨ããç¶æ³ã«ã
ããããããããã²ã¨ã¤ã®çµ±ä¸ããæåã³ã¼ããã¤ãããï¼ãã¨ãããã¨ã§ãUnicodeããä½ããããã¨ã«ãªãã¾ããã
Unicodeã使ãã¨ãã¯ãU+12ABã®ããã«16é²æ°ã®å
é ã«U+ãã¤ãã¦è¡¨ããã¨ã«ãã¦ã
U+0000ï½U+FFFFã®216ãã¿ã¼ã³ã§ä¸ã®ä¸ã®æåã表ããï¼ã£ã¦ãã¨ã§Unicode1.0ãçã¾ããããã§ãã
ãµãã²ã¼ããã¢ã®èªç
ã¨ããããç¹ã«ã¢ã¸ã¢åã®æåã表ããã¨ãããããã§ã¯å ¨ç¶è¶³ããªãã¦ãU+10FFFFã¾ã§Unicodeãæ¡å¼µãããã¨ã«ãªãã¾ããã
ãããããã ã¨1æå表ç¾ããã®ã«21bitå¿ è¦ã§ã2nãããªãã®ã§ã¨ã£ã¦ãåããæªãã¨ããäºæ ã«ã
ããã§ããã¨ãã¨Unicode1.0ã§ä½¿ããã¦ãã16bitã§ãªãã¨ã表ç¾ããããã«ã
ãã¾ãã¾æªä½¿ç¨ã ã£ãD800Hï½DFFFHã2ã¤çµã¿åããã32bitã使ã£ã¦U+10000以ä¸ã表ç¾ããã¨ããããããããªæ¹æ³ãçºæãããããã§ãããããããµãã²ã¼ããã¢ãã
ã§ãU+0000ï½U+FFFFã®æåãBMP(Basic Multilingual Plane, åºæ¬å¤è¨èªé¢)ãU+010000ï½U+10FFFFã¾ã§ã®æåãSMP(Supplementary Multilingual Plane, 追å å¤è¨èªé¢)ã¨å¼ã¶ãã¨ã«ããããã§ãã
UTF-XX
ä¸è¨ã®ãããªçµç·¯ãè¸ã¾ããå®éã«ãã¼ã¿ä¸ã§ã©ã表ããã¨ãããã¨ã³ã³ã¼ãæ¹å¼ãããã¤ãèããããããã§ãã
UTF-16ãâãä¸ã®éãã®ãµãã²ã¼ããã¢ããã®ã¾ã¾å®è£ ãããä¸æåã«16bit使ãã¨ã³ã³ã¼ãæ¹å¼ãä¸çªæ£ç´ã
UTF-32ãâããµãã²ã¼ããã¢ã¯ãããããã®ã§ããã¹ã¦ã®æåã«å¯¾ãã¦32bitãå²ãå½ã¦ãæ¹å¼ãä¸çªãããæããã©ãä¸çªç¡é§ãå¤ãã
UTF-8ãâãæåã«åããã¦ã8bit, 16bit, 24bit, 32bitã®ã©ããã使ãããã«ãã¦ãããUnicodeã®ä¸ã§ã¯ç¡é§ãä¸çªå°ãªããæãæ®åãã¦ããã
Javaã§ã®SMP
å°ã話å¤ãã£ã¦Javaã®ã話ã
çªç¶ã§ãããJavaã®ããªããã£ãå¤æ°ã®charåã¯ãä¸éã (char) 0xFFFF ãªã®ã§ããªãã¨SMPã«å²ãå½ã¦ãããæåã表ç¾ã§ããªãããã§ãï¼
ããã§ãJava5.0以éãä¸è¨ã®ãµãã²ã¼ããã¢ã®èãæ¹ãæµç¨ãã¦ãSMPã¯ãchar2ã¤ã§1æåã表ãããã«ãã¦ãã¾ãã
Javaã§ã®ãµãã²ã¼ããã¢ã®æ±ãã«ã¤ãã¦ã¯ãã®è¨äºãããããããã£ãã§ãã
Java ã¨ãµãã²ã¼ããã¢ã«ã¤ã㦠- ã«ããã«ããããã°
Spring Web Serviceãè¨ããã¨ãèãã¾ããï¼
â¦ã¨ãããã¾ã§èª¬æãã¦ããããç§ã®èº«ã«èµ·ãã£ããã¨ãã
ããããããã¾ãã¦ãXMLä¸ã«U+1F6ADã®ãããªSMPãåºåããå¿ è¦ãããã¾ããã
XMLã®ä»æ§çã«ã¯åç´ã§ãæ°å¤æååç §ã使ã£ã¦ 🚭 ã¨ã 🚭 ã¨è¡¨ç¾ã§ããã°OKã§ãã
ä¸æ¹ãç§éã®ãµã¼ãã¹ã§ã¯Spring Web Serviceã¨ããSOAPã¢ããªã®ããã®ãã¬ã¼ã ã¯ã¼ã¯ã使ã£ã¦ãã¾ãã
ããã¤ãæ®æ®µã¯ãªããªã便å©ãªåã§ãã¦ãEndPointã®ã¬ã¹ãã³ã¹ã¨ãã¦BeanãReturnããã¨ããã®Beanã®é層æ§é ããã®ã¾ã¾åæ ããXMLãä½ã£ã¦ãããã®ã§ãã
ã¾ããXMLä¸å¿
è¦ãªã¨ã¹ã±ã¼ããèªåã§è¡ã£ã¦ããã¦ããã¨ãã°ãï¼ããæååã®å¤ã¨ãã¦å«ã¾ãã¦ããããXMLãåºåããéã«ã¯ãã¡ãã¨ã&ãã¨åºåãã¦ããããã¨ããå
·åã§ãã
ã§ã¯ããã®Spring Web Serviceã使ã£ãæã«ã
ã¬ã¹ãã³ã¹ã®Beanã«å«ã¾ãã hoge ãã£ã¼ã«ãã«ãð(U+1F6AD)ãå
¥ã£ã¦ãããã©ããªããï¼ï¼
ãªãããããããï¼ï¼
55357 = D83DH, 57005 = DEADHã§ããµãã²ã¼ããã¢ã«å解ãããä¸ã§å®ä½åç §ã¨ãã¦è¡¨ç¾ããã¦ãã¾ãã
ãããããString hoge å ã®charã®é åãé ããé ã«1æåãã¤å¦çãã¦ããã ãããªãâ¦ãã¨æ¨æ¸¬ããã¾ãã
æ´ã«è¯ããªããã¨ã«ãD800Hï½DFFFHã¯Unicodeã§ã¯åç¬ã§åå¨ã§ããªãæåãªã®ã§ãä¸è¨�ã�ã¯XMLä¸ä½¿ããªãæåã§ãããããå«ã¾ããXMLã¯æ£ãããã¼ã¹ããã¾ããã
Â
çµå±ç¾ç¶ã§ãXMLãç ´å£ããªãããã«ã¯ãCharacter#isSupplementaryCodePoint methodã使ã£ã¦ãSMPãé¤å¤ãã以å¤æ¹æ³ããªãããã
ãã¼ãâ¦ã
ãã¾ããOracleä¸ã§ã¯
ããããã®ç¦ç ãã¼ã¯ãOracleï¼UTF-8ã¨ã³ã³ã¼ãã§ï¼ã«å ¥ã£ã¦ãå ´åã©ããªãã
select ascii(hoge) from hoge_table;
-> 4036991661
ãããµã
ããã¯ã4036991661 = F09F9AADH ã§ãã¦ãSMPãUTF-8ã§è¡¨ç¾ããå ´åãããããããããã«ã¼ã«ã§ããããã§ããæ°å¤ã«å¤æãããããâ¦ã¿ããã§ãã