www.webdeveloper.com
Results 1 to 5 of 5

Thread: Display character encoding

  1. #1
    Join Date
    Jun 2007
    Posts
    96

    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

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    If you are talking about HTML/XHTML files, the encoding is given by the specific meta tag written in the HEAD section:
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    I don't understand your aim, however...

  3. #3
    Join Date
    Jun 2007
    Posts
    96
    Quote Originally Posted by Kor View Post
    If you are talking about HTML/XHTML files, the encoding is given by the specific meta tag written in the HEAD section:
    Code:
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    I don't understand your aim, however...
    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?

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    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...t-encoding.php

    And even so, you can detect the encoding of a certain string there, not exactly how the whole document was encoded for...

  5. #5
    Join Date
    Jun 2007
    Posts
    96
    Thanks a lot.

    I'll give PHP a go

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles