Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASCII Problem #2

Closed
koalalorenzo opened this issue Nov 19, 2013 · 2 comments
Closed

ASCII Problem #2

koalalorenzo opened this issue Nov 19, 2013 · 2 comments

Comments

@koalalorenzo
Copy link

I noticed that when I create a new update using these codes:

[Other code]
facebook_profile = Profiles(api=api).filter(_id="50a29021d932############")[0]
fb_media = None
if main_picture:
    fb_media = {
        "picture": main_picture,
        "thumbnail": main_thumbnail
    }
facebook_profile.updates.new(smart_str(fb_text), media=fb_media)

I Got this exception:

File "/Users/koalalorenzo/Documents/Dropbox/Progetti/Reali Network/reali-bufferizer/src/buffer-python/buffpy/managers/updates.py", line 110, in new
     post_data += "profile_ids[]=%s&" % self.profile_id
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 59: ordinal not in range(128)

So I checked if the profile_id is not ASCII but it is. So I tried to use django smart_str to fix it but it does not work. My text is imported from XML using UTF-8 and converted to ASCII using this line:

 descrizione = descrizione.decode(xml_obj.encoding).encode('ascii', 'xmlcharrefreplace')

What is my mistake? Is the profile_id not ascii? Is that ID the ID I gave( _id="50a29021d932############" ) ? The string is ASCII!

@vtemian
Copy link
Owner

vtemian commented Nov 21, 2013

Hey,

Well, obvious an input is not ASCII when it been passed to facebook_profile.updates.new(smart_str(fb_text), media=fb_media)
Can you check fb_text to be ASCII by print "%s" % descrizione?

Anyway, we should fix this in order to support unicode, because facebook and twitter supports unicode and if we convert unicode to ascii, we will remove all special characters, which sucks big time.

@koalalorenzo
Copy link
Author

Yes descrizione was not ASCII code. The strange fact is that i made it ASCII using the "decode" and "encode". so I don't know why it was not working. Anyway I hope everything will be updated to unicode ASAP 👍

Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants