프로젝트 중에, JEUS 를 사용하는데 (제우스6), JSP 나 Action 은 모두 Response Header 에, Content-Type 이 UTF-8 로 잘 넘어오지만, 유독 JS 파일을 받을 때, euc-kr 로 넘어오더라. 

 JEUS 에서, 기본적으로, Encoding 정보가 별도로 없으면, euc-kr 로 넘기는 듯 싶다. Jeus 6 의 경우, WEBMain.xml 에서, 기본 인코딩 정보를 아래와 같이 설정해주면 된다.
<context-group>
...
<encoding>
        <request-url-encoding>
                <default>UTF-8</default>
        </request-url-encoding>
        <request-encoding>
                <default>UTF-8</default>
        </request-encoding>
        <response-encoding>
                <default>UTF-8</default>
        </response-encoding>
</encoding>
...
</context-group>



또, 아래 정보는 어디서 퍼온 것인데, JavaScript 별로, charset 을 지정해 줄 수 있다.

International Language Support in JavaScript

JavaScript is built to support a wide variety of world languages andtheir characters – from the old US ASCII up to the rapidly spreadingUTF-8. This page clears up some of the difficulties encountered whendealing with multiple languages and their related characters.

JavaScript and Character Sets

When working with non-European character sets ("charsets"), you mayneed to make changes to the way your page references externalJavaScript(.js) files. Ideally, your .js files should saved in theUTF-8 character set in order to maximize its multilingual features —though you can use a different charset that supports your language, atthe potential expense of users who can't support it. Once your filesare saved as UTF-8, they must be "served" in the UTF-8 charset in orderto display correctly. There are a few ways to ensure this:

Serve the Web Page as UTF-8

If your page is already served as UTF-8 (i.e. Content-type=text/html; charset=UTF-8),you don't need to make any changes — all embedded files in an HTMLdocument are served in the same charset as the document, unlessexplicitly specified not to by you. You can do this by:

  • Use the Content-type meta tag — place at the TOP of your page's <head> section.

    <meta name="http-equiv" content="Content-type: text/html; charset=UTF-8"/>)
  • Edit your webserver configuration to serve all documents as UTF-8
  • Send the Content-type header via your server-side scripts (i.e. PHP, ASP, JSP)

Use the charset attribute of the <script> tag

The easiest way to ensure your script is served as UTF-8 is to add acharset attribute (charset="utf-8") to your <script> tags in theparent page:

<script type="text/javascript" src="[path]/myscript.js" charset="utf-8"></script>

Modify your .htaccess files (Apache Only)

You can also configure your webserver to serve all .js files in theUTF-8 charset, or only .js files in a single directory. You can do thelatter (in Apache) by adding this line to the .htaccess file in the directory where your scripts are stored:

AddCharset utf-8 .js
반응형
블로그 이미지

Good Joon

IT Professionalist Since 1999

,