/    Sign up×
Community /Pin to ProfileBookmark

Display character encoding

Hi Guys,

I’ve been fiddling with this for a while now and can only find out how to convert / change character encoding.

I want to write something super small that will just display the character encoding of a file i specify.

Can somebody give me some guidance of where to start?

Thanks,
Liam

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorSep 26.2011 — If you are talking about HTML/XHTML files, the encoding is given by the specific meta tag written in the HEAD section:
<i>
</i>&lt;meta http-equiv="Content-Type" content="text/html; [COLOR="Blue"]charset=utf-8[/COLOR]"&gt;


I don't understand your aim, however...
Copy linkTweet thisAlerts:
@dntelauthorSep 26.2011 — If you are talking about HTML/XHTML files, the encoding is given by the specific meta tag written in the HEAD section:
<i>
</i>&lt;meta http-equiv="Content-Type" content="text/html; [COLOR="Blue"]charset=utf-8[/COLOR]"&gt;


I don't understand your aim, however...[/QUOTE]


What I actually wanted to do was write a small function that could browse for a file and tell you the encoding that was currently on it.

At work I have to sometimes check the file encoding of files because scripts require them to be a certain one.

Is that clearer? ?
Copy linkTweet thisAlerts:
@KorSep 26.2011 — ok, understood.

I am afraid that JavaScript alone can neither browse other files from a server nor to detect their encoding type. A server-side language would be the proper choice. If PHP, see also:

http://php.net/manual/en/function.mb-detect-encoding.php

And even so, you can detect the encoding of a certain string there, not exactly how the whole document was encoded for...
Copy linkTweet thisAlerts:
@dntelauthorSep 26.2011 — Thanks a lot.

I'll give PHP a go ?
×

Success!

Help @dntel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...