본문 바로가기

엔코딩3

엔코딩/디코딩 함수 1. escape(), unescape() ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890@*-_+./ 위 문자를 제외한 모든 문자를 %XX 형태로 변환한다.…2. encodeURI(), decodeURI() escape()와 동일한 변환을 한다. 단, :;/=?& 는 변환하지 않는다.…3. encodeURIComponent(), decodeURIComponent() :;/=?& 까지 포함해서 변환을 한다. 인터넷 주소를 한의 변수에 담을 때, 사용 가능ㅎ다. encodeURIComponent()를 사용하는 것은 UTF-8로 인코딩하는 것과 같다.…* java.net.URLEncoder는 encodeURI()와 동일한 기능을 한다. 단, U.. 2014. 1. 17.
[Java] GET 방식으로 전달된 한글 깨짐현상 jsp 에서 get 방식으로 데이터를 전달할때, 한글이 깨지는 현상이 발생하곤 한다. 이때, 해결 방법은 전달전에 엔코딩을 해서 전달 한 후에 jsp 에서 디코딩을 해서 사용하는 것이다.… Javascript 에서 다음과 같이 엔코딩 해서 한글을 넘긴다. location.href = “test.jsp?name=” + encodeURI(“한글나라”, “UTF-8″);… JSP 에서 다음과 같이 디코딩해서 사용한다. String name = java.net.URLDecoder.decode(request.getParameter(“name”), “UTF-8″); 2013. 11. 15.
[Java] Base64로 encoding된 파일을 decoding 해서 저장하기 이전 Article “HTTP POST 로 타서버로 파일 전송” 에서 전달된 Base64 로 encoding 된 파일을 받아서 decoding 하는 예제이다.… import org.apache.commons.codec.binary.Base64OutputStream;… stream = formFile.getInputStream(); // Base64로 encoding 된 파일 OutputStream bos = new Base64OutputStream(new FileOutputStream(“저장경로를 갖는 파일명”), false); int bytesRead = 0; byte[] buffer = new byte[8192]; while ((bytesRead = stream.read(buffer, 0, 8192).. 2013. 11. 15.