• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2101
  • Last Modified:

Character encoding for .js files

Hello,

This is in the header sent by my server for all .js files:

Content-Type:·application/x-javascript(CR)(LF)

Can I encode my .js files in UTF-8 then send this header?

Content-Type:·application/x-javascript;·charset=UTF-8(CR)(LF)

Or could that  cause bugs?

Thanks!
0
hankknight
Asked:
hankknight
1 Solution
 
stanscott2Commented:
Javascript internally works with all text in Unicode, so there shouldn't be a problem.  Where you're using Javascript to pass data on to server-side scripts, you should be careful to use encodeURIComponent() and encodeURI().

The encodeURI() function encodes entire URIs  so it leaves characters such as :?& intact. encodeURIComponent() encodes strings to be individual parameters of a URI, so it encodes all characters except ~!*().
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now