한글이나 일본어가 깨지는 현상때문이었는데요. 파일도 utf-8(without BOM), 그리고 groovy.exe의 실행옵션에서 도움말에 있는 --encoding UTF-8 이나 -c UTF-8을 아무리 주어도 제대로 표시되지 않았습니다. 아파치의 설정이 잘못된 것인지도 보고, 옵션이 먹지 않는지 레지스트리의 .groovy파일 실행할 때 디폴트 옵션을 줘보기도 했습니다만, 해결은 다른 방법으로 되었습니다. 옵션에 -Dfile.encoding=UTF-8 을 주고 실행하는 것이었습니다.
아마도, 스펙대로라면 -Dfile.encoding=UTF-8 이 없어도 잘 표시되어야 할 것 같은데...., 잘 되지 않았습니다.
- #!C:\Progra~1\Java\groovy-1.6.0\bin\groovy.exe -Dfile.encoding=UTF-8
- //C:\Progra~1\Java\groovy-1.6.0\bin\groovy.exe -c utf-8 -D file.encoding=UTF-8
- import java.net.URLDecoder;
- def decoder = URLDecoder;
- print "Content-type: text/html\n\n"
- print "<html><head><meta content='text/html; charset=utf-8' http-equiv='Content-Type'/></head><body>"
- def name='World'; println "Hello $name!"
- /* == to show all env variables
- def env = System.getenv()
- for(k in env){
- println(k)
- } */
- def __form = [:]
- def arrykeyvalue
- def strQueryString = System.getenv()['QUERY_STRING']
- if (strQueryString != null) {
- def arryForm = strQueryString.split('&')
- arryForm.each {
- arrykeyvalue = it.split('=')
- __form.put(arrykeyvalue[0], arrykeyvalue[1])
- }
- }
- __form.each {
- print (it.key + ' = ' + it.value+ '<br>')
- }
- __form.each {
- print (it.key + ' = ' + decoder.decode(it.value, "UTF8") + '<br>')
- }
- print "日本語 <br> "
- print "한국어 <br> "
- print "</body></html>"
html 태그가 있어 본문에 에러가 있다고 하니 일본어의 전각 괄호로 바꾸었습니다.
그리고 아래가 실행 내용입니다.

No comments:
Post a Comment