Add new encoder
This encoder is used to handle input from HH conversion, which needs to end up as UTF-8 in the database. Switch the open-coded routine from Database.py to this common routine so all encodings now take place in the same file.
This commit is contained in:
		
							parent
							
								
									6dcec48005
								
							
						
					
					
						commit
						33277ce68b
					
				|  | @ -40,6 +40,16 @@ def to_utf8(s): | |||
|         print 'Could not convert: "%s"' % s | ||||
|         raise | ||||
| 
 | ||||
| def to_db_utf8(s): | ||||
|     if not_needed: return s | ||||
| 
 | ||||
|     try: | ||||
|         (_out, _len) = encoder_to_utf.encode(unicode(s)) | ||||
|         return _out | ||||
|     except UnicodeDecodeError: | ||||
|         print 'Could not convert: "%s"' % s | ||||
|         raise | ||||
| 
 | ||||
| def to_gui(s): | ||||
|     if not_needed: return s | ||||
| 
 | ||||
|  |  | |||
|  | @ -1558,7 +1558,7 @@ class Database: | |||
| 
 | ||||
|     def insertPlayer(self, name, site_id): | ||||
|         result = None | ||||
|         _name = Charset.to_utf8(name) | ||||
|         _name = Charset.to_db_utf8(name) | ||||
|         c = self.get_cursor() | ||||
|         q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s" | ||||
|         q = q.replace('%s', self.sql.query['placeholder']) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user