FTP with special character in password - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: FTP with special character in password (/thread-25522.html) |
FTP with special character in password - amatta - Apr-01-2020 Hello I am new to python and i am trying to connect to FTP to download files. The FTP password provided by vendor has a special character '(apostrophe) in it. To resolve error: UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 12: ordinal not in range(256) I used encode('cp1252') in my ftps login but then the problem is login at FTP site fails with error_perm: 530 Login or password incorrect! How do you get around this issue ? Thanks! RE: FTP with special character in password - BrendanD - Apr-01-2020 Use a raw string? RE: FTP with special character in password - amatta - Apr-01-2020 Thank you for your response but using raw string also results in UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 12: ordinal not in range(256) RE: FTP with special character in password - BrendanD - Apr-02-2020 I am assuming you have already tested the ftp from the command line or from a GUI? Have you tried utf-8 or ansi encoding? RE: FTP with special character in password - amatta - Apr-02-2020 Yes, i did try the credentials in GUI and it works there. I did try the UTF8 also but no luck. the additional charactrs that replace ' in the password fail the connection RE: FTP with special character in password - BrendanD - Apr-02-2020 How about normalizing your password string first? import unicodedata norm_password = unicodedata.normalize('NFKD', password)Edit: u2019 is a right apostrophe. Maybe you need a different one? See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html i.e. "\u27" |