Results 1 to 9 of 9

Thread: Character encoding problem

  1. #1
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Character encoding problem

    In the head of my document i have
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    and in the body the text "años" but the ñ is being corrupted when I look at the page in IE6 or Firefox.

    I have checked both browsers and their encoding is also UTF-8. However, if I change the browser encoding to Western European the "ñ" shows correctly. If I View Source in IE, the "ñ" also shows correctly but View Source in Firefox replaces the "ñ" with a question mark.

    Can anybody tell me why the characters are not rendering correctly.
    Cheers
    Billy

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Are you using its character code?
    the codes are usually similar to &amp;
    http://www.asciitable.com/
    So put
    &164;
    in the source where you want the n.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    I am already using coding like this but think it should not be necessary. I am certain that sites in Spanish, for example, would be a nightmare to build if every non-English character had to be coded like that.
    Cheers
    Billy

  4. #4
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    It is nessesary.
    html is in english, so are the character codes.

    also, ascii doesnt support any characters other than the ones in the first picture in the link i gave you.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  5. #5
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Yeah I've just had a look at a Spanish site and they use the codes.

    Thanks for that.
    Cheers
    Billy

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I am already using coding like this but think it should not be necessary.
    You're quite right, it shouldn't be.
    Code:
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    Be aware that this will be overridden if a character set is specified in the HTTP headers (which is the preferred place to specify the character set).
    I have checked both browsers and their encoding is also UTF-8. However, if I change the browser encoding to Western European the "&#241;" shows correctly. If I View Source in IE, the "&#241;" also shows correctly but View Source in Firefox replaces the "&#241;" with a question mark.
    You've specified UTF-8 (assuming that hasn't been overridden), but it sounds as though the file is actually in ISO-8859-1. Make sure you're saving the file as UTF-8 (it's an option in the save dialogue of Notepad; most other text editors will have something similar).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thanks, Twey, but how do I check or change HTTP headers? The pages are hosted on a service provider - do they decide what header is provided?

    With regard to writing the files, I use VB6 to output the .htm file. However, I have verified that the output is not putting in any "funnies" by opening the .htm files in metapad.
    Cheers
    Billy

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Thanks, Twey, but how do I check or change HTTP headers? The pages are hosted on a service provider - do they decide what header is provided?
    The headers sent can be checked with a browser plugin or extension, or by connecting to your webserver with a plain-text application such as telnet:
    Code:
    twey@peordh /home/twey $ telnet twey.co.uk 80
    Trying 82.110.105.24...
    Connected to twey.co.uk.
    Escape character is '^]'.
    HEAD / HTTP/1.1
    Host: twey.co.uk
    Connection: close
    
    HTTP/1.1 200 OK
    Date: Sat, 24 Mar 2007 14:23:24 GMT
    Content-Type: text/html;charset=utf-8;
    Expires: Sat, 24 Mar 2007 14:23:24 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Connection: close
    Server: Apache/2.0.55 (Red Hat)
    X-Powered-By: PHP/4.4.4
    Pragma: no-cache
    Set-Cookie: PHPSESSID=c2b041c0446210e8f8d6f58995933c02; path=/
    With regard to writing the files, I use VB6 to output the .htm file. However, I have verified that the output is not putting in any "funnies" by opening the .htm files in metapad.
    There's nothing wrong with the file, it's just not UTF-8. I can't remember how to specify the character encoding to use when writing to a file in VB6, but an equally valid solution would be to change your headers or <meta> elements to use the correct encoding (ISO-8859-1) instead of UTF-8.

    Also note that if you use <meta> elements to declare the character encoding, your character encoding of choice must be ASCII-compatible.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jul 2005
    Posts
    101
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Using the ISO encoding has solved the problem. Thanks a lot, Twey
    Cheers
    Billy

Bookmarks

Posting Permissions

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