JAVA 한글 2Byte 처리방법
2017. 11. 1. 21:52
Mobile/Android
JAVA 한글 2Byte 처리방법 JAVA에선 한글도 1글자, 영문이나 다른 글자도 1글자로 취급되어 substring된다. 이게 통신같은데선 문제가 될 수 있음. 한글은 2Byte, 그 외는 1Byte로 취급하는 함수 필요. 참고로 한글을 UTF-8(안드로이드 스튜디오 기본 인코딩 방식)로 취급시 getbyte()시, 한글은 3Byte, 그 외에는 1Byte로 처리됨. EUC-KR로 인코딩 방식을 변경하면 한글은 2Byte, 나머지는 1Byte로 처리. private String subString(String strData, int iStartPos, int iByteLength) { byte[] bytTemp = null; int iRealStart = 0; int iRealEnd = 0; int i..