Changeset 3423be0 for skype


Ignore:
Timestamp:
2011-02-07T23:24:37Z (14 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
d5a66f8
Parents:
c899eb0
git-author:
Philippe Crama <pcfeb0009@…> (07-02-11 23:24:37)
git-committer:
Miklos Vajna <vmiklos@…> (07-02-11 23:24:37)
Message:

Always use UTF-8 encoding when dealing with BitlBee

BitlBee internally always uses UTF-8 (see initialization of
irc->iconv and irc->oconv in set_eval_charset in irc.c of
BitlBee's source and their usage in eg irc_vawrite in the
same file; confirmed on #bitlbee), so it makes no sense to
either get an encoding from the current locale or to make it
a runtime setting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skyped.py

    rc899eb0 r3423be0  
    237237                        msg_text = [msg_text]
    238238                for i in msg_text:
    239                         # use utf-8 here to solve the following problem:
    240                         # people use env vars like LC_ALL=en_US (latin1) then
    241                         # they complain about why can't they receive latin2
    242                         # messages.. so here it is: always use utf-8 then
    243                         # everybody will be happy
    244                         e = i.encode('UTF-8')
     239                        try:
     240                                # Internally, BitlBee always uses UTF-8 and encodes/decodes as
     241                                # necessary to communicate with the IRC client; thus send the
     242                                # UTF-8 it expects
     243                                e = i.encode('UTF-8')
     244                        except:
     245                                # Should never happen, but it's better to send difficult to
     246                                # read data than crash because some message couldn't be encoded
     247                                e = i.encode('ascii', 'backslashreplace')
    245248                        if options.conn:
    246249                                dprint('<< ' + e)
     
    260263                        return
    261264                try:
    262                         encoding = locale.getdefaultlocale()[1]
    263                         if not encoding:
    264                                 raise ValueError
    265                         e = msg_text.decode(encoding)
    266                 except ValueError:
     265                        # Internally, BitlBee always uses UTF-8 and encodes/decodes as
     266                        # necessary to communicate with the IRC client; thus decode the
     267                        # UTF-8 it sent us
    267268                        e = msg_text.decode('UTF-8')
     269                except:
     270                        # Should never happen, but it's better to send difficult to read
     271                        # data to Skype than to crash
     272                        e = msg_text.decode('ascii', 'backslashreplace')
    268273                dprint('>> ' + e)
    269274                try:
Note: See TracChangeset for help on using the changeset viewer.