Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:35:12+00:00 2026-05-28T04:35:12+00:00

We can declare the character encoding in an INDIVIDUAL CSS file by codes below:

  • 0

We can declare the character encoding in an INDIVIDUAL CSS file by codes below:

@charset "UTF-8";

My question is:

How to declare character encoding in an INDIVIDUAL JS file?

If I send a JS file to my friend, I hope he (she) can understand this JS file’s character encoding from codes themselves when he (she) starts to browse or edit this JS file.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:35:12+00:00Added an answer on May 28, 2026 at 4:35 am

    You can’t. You can, however, define it in the script tag that brings the file into the page, using the charset attribute. This must match the charset, if any, in the Content-Type that you serve the file with. Quoting:

    The charset attribute gives the character encoding of the external script resource. The attribute must not be specified if the src attribute is not present. If the attribute is set, its value must be a valid character encoding name, must be an ASCII case-insensitive match for the preferred MIME name for that encoding, and must match the encoding given in the charset parameter of the Content-Type metadata of the external file, if any. [IANACHARSET]

    Re your edit:

    If I send a JS file to my friend, I hope he (she) can understand this JS file’s character encoding from codes themselves when he (she) starts to browser or edit this JS file.

    For that, you’ll pretty much just have to tell him/her. If the file is in UTF-8 or Windows-1252 or ISO 8859-1, unfortunately there’s no in-file indicator of the encoding available, so I’d include a comment at the beginning along the lines of:

    // Encoding: UTF-8
    

    If you’re using UTF-16 or UTF-32, though, you should be able to tell your editor to use a BOM, which other editors should see and understand (if they’re Unicode-aware editors). This would typically only apply if you were writing your comments in a text (language) requiring lots of multi-byte characters, and if you have a high ratio of comments to code (since the code is written with western text), although of course you’re welcome to use any encoding you like. It’s just that if the ratio of comments to code is low, you’re probably better off sticking with UTF-8 even if the comments are in a text requiring lots of four-byte characters, because the code will only require one byte per character. (Whereas in UTF-16, you might have more two-byte instead of four-byte characters in your comments, but the code would always require two bytes per character; and in UTF-32, four bytes per character. So on the whole the file may well be larger even though the comments take less space. But here I’m probably telling you things you already know far better than I, if I’m guessing correctly about your reasons for the question.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can: declare @idOrder int set @idOrder = 21319 I want: declare @idOrder int
In Oracle I can declare a reference cursor... TYPE t_spool IS REF CURSOR RETURN
Is there any way can declare a bean in just like JSP UseBean in
How i can declare a global method in delphi prism using the __Global class?
In PHP 5 I can declare a const value to a class: class config
In VB.Net, I can declare a variable in a function as Static, like this:
In Java, one can declare a variable parameterised by an unknown generic type, which
I'm familiar with how type affinity works in SQLite: You can declare column types
In MatLab, you can declare symbols pretty easily: syms a,b mat = [a,b] I'm
In asp classic and vbscript, you can declare a Const with a hexidecial value,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.