Re: Is it possible to use non-ascii characters in *.txt files?

56 views
Skip to first unread message

Pekka Klärck

unread,
Nov 2, 2012, 4:53:19 PM11/2/12
to ahry...@gmail.com, robotframe...@googlegroups.com
2012/11/1 andriyko <ahry...@gmail.com>:
>
> I work on email&mbox libraries for RF.
> Encountered a problem with MIME objects with custom charsets and encodings.
>
> In Python
>
> from_header = email.header.Header()
> from_header.append(u'Петро')
> from_header.append('<so...@mail.com>')
> msg['From']=from_header
>
> An attempt to use Петро in txt file
> UnicodeEncodeError: 'ascii' codec can't encode characters in position

It is possible have non-ASCII characters both in Python code and in
Robot Framework data. With Python code you need to specify the source
code encoding explicitly [1], and with Robot data you just must use
UTF-8 encoding.

[1] http://www.python.org/dev/peps/pep-0263/

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
Reply all
Reply to author
Forward
0 new messages