Css and Unicode

Discussion in 'CSS' started by Gittik, Aug 29, 2008.

  1. #1
    Hey all,

    I'm making a website in two languages - one version in English and one version in Russian. The English version, saved as ANSI files, is fine. However, the Russian version, saved as Unicode files (otherwise cyrillic turns to gibberish), fails to load the .css file when browsed in Firefox (IE loads everything perfectly).

    For the record, the coding in the two versions is the same, and the line relating the .css file to the .html files looks like this -

    <Link Href="Design.css" Type="Text/Css" Rel="Stylesheet" />
    Code (markup):
    The only solution I've found is to copy the entire .css file to each .html page, and I don't want to do that. Any ideas?

    Thanks in advance,

    Dan.
     
    Gittik, Aug 29, 2008 IP
  2. Uzi Levitovitch

    Uzi Levitovitch Active Member

    Messages:
    117
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Why don't you save your css as UTF-8 ?
    If I were you - I save all files as UTF-8, use meta tag to point to UTF-8 and select xhtml doctype...
     
    Uzi Levitovitch, Aug 29, 2008 IP
  3. Gittik

    Gittik Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Uzi,

    I am not familiar with UTF-8, and a quick search results explain what it is, rather than how to save .html and .css files... so any explanation about how to save and how to select xhtml doctype (and generally how to do what you suggested) would be great.

    Dan.
     
    Gittik, Aug 30, 2008 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    First, to save the files as utf-8, click save as. You should see a box that says something like 'character encoding'. Select utf-8. In any Windows editor, do not choose Unicode.

    In your html document, you should have this line in the <head> section:
      <meta http-equiv="Content-Type"
            content="text/html; charset=utf-8" />
    Code (markup):
    Open a document in your browser (one that's on your server host), and use Firefox's web developer extension to view the server response header. Using wget, DP's response header looks like this:
    gt@koko:~$ wget -S http://forums.digitalpoint.com
    --2008-08-30 12:34:55--  http://forums.digitalpoint.com/
    Resolving forums.digitalpoint.com... 216.9.35.60
    Connecting to forums.digitalpoint.com|216.9.35.60|:80... connected.
    HTTP request sent, awaiting response... 
      HTTP/1.1 200 OK
      Date: Sat, 30 Aug 2008 17:34:55 GMT
      Server: Apache
      Set-Cookie: bbsessionhash=ee9b9f86db066f7e5c3d82524bbbfe83; path=/; HttpOnly
      Set-Cookie: bblastvisit=1220117695; expires=Sun, 30-Aug-2009 17:34:55 GMT; path=/
      Set-Cookie: bblastactivity=0; expires=Sun, 30-Aug-2009 17:34:55 GMT; path=/
      Cache-Control: private
      Pragma: private
      Connection: close
      [color=red]Content-Type: text/html; charset=UTF-8[/color]
    Length: unspecified [text/html]
    Code (markup):
    If the header does not contain the hi-lited line, your document's http-equiv meta tag tells the browser which to use. The server header rules, and in the line's absence, the meta element provides backup.

    If your server response does have the line, but it says something other than utf-8, you'll need to use your .htaccess file to add the header (do it only if the default header specifies a charset and it's not utf-8. You're ok if it says nothing).
    
    AddDefaultCharset UTF-8
    Code (markup):
    Put that in your document root directory's .htaccess file.

    cheers,

    gary
     
    kk5st, Aug 30, 2008 IP