Fix unicode error of device user's non-english name.

This commit is contained in:
Bayarkhuu Bataa 2019-07-24 16:10:06 +08:00
parent 19f3133e92
commit 8f887a2037

View File

@ -34,7 +34,7 @@ class User(object):
return pack("<BHB8s24sIB7sx24s", 2, self.uid, self.privilege,self.password.encode(User.encoding, errors='ignore'), self.name.encode(User.encoding, errors='ignore'), self.card, 1, str(self.group_id).encode(User.encoding, errors='ignore'), str(self.user_id).encode(User.encoding, errors='ignore')) return pack("<BHB8s24sIB7sx24s", 2, self.uid, self.privilege,self.password.encode(User.encoding, errors='ignore'), self.name.encode(User.encoding, errors='ignore'), self.card, 1, str(self.group_id).encode(User.encoding, errors='ignore'), str(self.user_id).encode(User.encoding, errors='ignore'))
def __str__(self): def __str__(self):
return '<User>: [uid:{}, name:{} user_id:{}]'.format(self.uid, self.name, self.user_id) return u'<User>: [uid:{}, name:{} user_id:{}]'.format(self.uid, self.name, self.user_id)
def __repr__(self): def __repr__(self):
return '<User>: [uid:{}, name:{} user_id:{}]'.format(self.uid, self.name, self.user_id) return u'<User>: [uid:{}, name:{} user_id:{}]'.format(self.uid, self.name, self.user_id)