The unfortunate problem with this patch is that oscar.py can not have  
knowledge of config.py.  oscar.py is intended to be ported  
elsewhere.  That said, thanks for the patch and, at some point,  
hopefully all of the encoding issues will be worked out.  (some of  
them are awefully weird and hard to work with)

Daniel

On Jun 20, 2006, at 10:33 AM, Alexey A. Nikitine wrote:

> Hello.
>
> I've met a problem with PyICQ-t (latest SVN):
> When I compose messages in cyrillic, some remote ICQ clients receive
> them in an unreadable encoding. Those are the clients without (or  
> with a
> buggy) unicode support.
>
> I have fixed it, patches are attached. The patches surely won't affect
> other users if they set iso-8859-1 as a default encoding in their
> config.xml. Russian users would be happy with CP1251 here.
>
> <!-- Default message encoding to use -->
> <encoding>iso-8859-1</encoding>
>
> Thank you.
>
> --
> Alexey Nikitine.
> --- utils.py  2006-04-28 07:04:37.000000000 +0400
> +++ utils.py  2006-06-20 15:27:35.000000000 +0400
> @@ -49,7 +49,7 @@ for c in _excluded: excluded[c] = None
>               try:
>                       us = unicode(s)
>               except UnicodeDecodeError:
> -                     us = unicode(s, 'iso-8859-1')
> +                     us = unicode(s, config.encoding)
>               return us.translate(excluded)
>       elif s.__class__ == unicode:
>               return s.translate(excluded)
> --- oscar.py  2006-05-31 06:30:16.000000000 +0400
> +++ oscar.py  2006-06-20 16:02:34.000000000 +0400
> @@ -31,6 +31,7 @@ from scheduler import Scheduler
>  import threading
>  import socks5, sockserror
>  import countrycodes
> +import config
>
>  def logPacketData(data):
>      # Comment out to display packet log data
> @@ -862,7 +863,7 @@ from scheduler import Scheduler
>          self.connectPort = 5190
>          # Note that this is "no unicode" default encoding
>          # We use unicode if it's there
> -        self.defaultEncoding = 'iso-8859-1'
> +        self.defaultEncoding = config.encoding
>
>          if not self.capabilities:
>              self.capabilities = [CAP_CHAT]
> @@ -2003,14 +2004,14 @@ from scheduler import Scheduler
>                      charSet = 0x0000
>                  except:
>                      try:
> -                        part[0] = part[0].encode('iso-8859-1')
> +                        part[0] = part[0].encode(config.encoding)
>                          charSet = 0x0003
>                      except:
>                          try:
>                              part[0] = part[0].encode('utf-16be',  
> 'replace')
>                              charSet = 0x0002
>                          except:
> -                            part[0] = part[0].encode('iso-8859-1',  
> 'replace')
> +                            part[0] = part[0].encode 
> (config.encoding, 'replace')
>                              charSet = 0x0003
>              if 'macintosh' in part[1:]:
>                  charSubSet = 0x000b
> @@ -2023,7 +2024,7 @@ from scheduler import Scheduler
>          # We'll investigate this in more detail later.
>          features = '\x01\x01\x02'
>          # Why do i need to encode this?  I shouldn't .. it's data.
> -        data = data.encode('iso-8859-1', 'replace') + TLV(2, TLV 
> (0x0501, features)+messageData)
> +        data = data.encode(config.encoding, 'replace') + TLV(2, TLV 
> (0x0501, features)+messageData)
>          if wantAck:
>              log.msg("sendMessage: Sending wanting ACK")
>              data = data + TLV(3)
> _______________________________________________
> py-transports mailing list
> [email protected]
> http://www.modevia.com/cgi-bin/mailman/listinfo/py-transports

Reply via email to