#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    9
    Rep Power
    0

    eval(...) function


    I'm using the following code:

    strUTF8=strQuoted.encode("UTF-8")
    print strUTF8
    strUnquoted=eval(strUTF8)
    print strUnquoted
    strUnquoted=unicode(strUnquoted, "utf-8")

    The output looks like:
    """whole degrees (\xb0)"""
    whole degrees (░)
    UnicodeError: UTF-8 decoding error: unexpected code byte


    I'm having to use '\xb0' for the degree symbol because the program does not support the symbol itself. Can anyone help with this error? Why does the eval(...) function return the box-like symbol? How can I get around this???
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    A box is usually the a unrecognised char. This is probably something to do with switching between encoding types. Why are you using eval?

    It seems to me that you are just setting strUnquoted to the value strUTF8. If so then you could just do strUnquoted = strUTF8.. you should probably make sure that \xb0 is the degree sign if your not 100% sure.

    Python's output by default is ascii, this could also be a reason why you are getting a box?

    Hope this is of some help,

    Have fun,
    Mark.

IMN logo majestic logo threadwatch logo seochat tools logo