Unicode in groups and names
HI all, First of all I want to thank you for the nice client and your hard effords for making it better every day.
I noticed two problems with Unicode - UTF conversions
- In accounts, which contain UTF-8 characters, e.g. киров@jabber.org, when added two the roster, the key is lost
- If the group is in UTF-8 string, its open/close status is not kept in the config.
I propose a patch, hope that will help, figure out where the problem is:
Index: src/common/connection.py
===================================================================
--- src/common/connection.py (revision 1773)
+++ src/common/connection.py (working copy)
@@ -315,13 +315,17 @@
def _rosterSetCB(self, con, iq_obj):
gajim.log.debug('rosterSetCB')
for item in iq_obj.getTag('query').getChildren():
- jid = item.getAttr('jid')
+ jid = item.getAttr('jid').encode('utf8')
name = item.getAttr('name')
- sub = item.getAttr('subscription')
+ if name:
+ name = name.encode('utf8')
+ sub = item.getAttr('subscription').encode('utf8')
ask = item.getAttr('ask')
+ if ask:
+ ask = ask.encode('utf8')
groups = []
for group in item.getTags('group'):
- groups.append(group.getData())
+ groups.append(group.getData().encode('utf8'))
self.dispatch('ROSTER_INFO', (jid, name, sub, ask, groups))
raise common.xmpp.NodeProcessed
@@ -502,6 +506,15 @@
roster = self.connection.getRoster().getRaw()
if not roster :
roster = {}
+ else:
+ for i in roster.keys():
+ props = roster[i]
+ if props.has_key('name') and props['name']:
+ props['name']=props['name'].encode('utf8')
+ if props.has_key('groups') and props['groups']:
+ props['groups']= map(lambda e:e.encode('utf8'),props['groups'])
+ if props.has_key('resources') and props['resources']:
+ props['resources']= map(lambda e:e.encode('utf8'),props['resources'])
name = gajim.config.get_per('accounts', self.name, 'name')
hostname = gajim.config.get_per('accounts', self.name, 'hostname')
if roster.has_key(name + '@' + hostname):