Thread: Encoding issue

    #1
  1. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13

    Question Encoding issue


    About my encoding issue at http://superhost.gr


    This works in the shell, but doesn't work on my website:

    $ cat utf8.txt
    υλικό!Πρόκειται γ
    $ python3
    Python 3.2.3 (default, Oct 19 2012, 20:10:41)
    [GCC 4.6.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> data = open('utf8.txt').read()
    >>> print(data)
    υλικό!Πρόκειται γ

    >>> print(data.encode('utf-8'))
    b'\xcf\x85\xce\xbb\xce\xb9\xce\xba\xcf\x8c!\xce\xa0\xcf\x81\xcf\x8c\xce\xba\xce\xb5\xce\xb9\xcf\x84\ xce\xb1\xce\xb9 \xce\xb3\n'

    See, the last line is what i'am getting on my website. If i remove the encode('utf-8') part in metrites.py, the webpage will not show anything at all...
    What is now proved was once only imagined!
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,850
    Rep Power
    481
    can you specify the html page encoding in the head?
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    Thessaloniki
    Posts
    1,280
    Rep Power
    13
    Originally Posted by b49P23TIvg
    can you specify the html page encoding in the head?
    How you mean?

    in the metrites.py script or in the index.html page that the metrites.py scipt is opening?

    i have this in both scripts:

    #!/usr/bin/python3
    # coding=utf-8

    in the metrites.py script

    and

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    in the index.html file
    What is now proved was once only imagined!

IMN logo majestic logo threadwatch logo seochat tools logo