Package Gnumed :: Package timelinelib :: Package general :: Module encodings
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.general.encodings

 1   
 2   
 3  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
 4  # 
 5  # This file is part of Timeline. 
 6  # 
 7  # Timeline is free software: you can redistribute it and/or modify 
 8  # it under the terms of the GNU General Public License as published by 
 9  # the Free Software Foundation, either version 3 of the License, or 
10  # (at your option) any later version. 
11  # 
12  # Timeline is distributed in the hope that it will be useful, 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
15  # GNU General Public License for more details. 
16  # 
17  # You should have received a copy of the GNU General Public License 
18  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
19   
20   
21  import sys 
22   
23   
24 -def to_unicode(string_data):
25 """ 26 Tru to encode a string into unicode. 27 """ 28 if isinstance(string_data, unicode): 29 return(string_data) 30 else: 31 for encoding in [sys.getdefaultencoding(), "utf-8", "cp1250", "cp850"]: 32 try: 33 return unicode(string_data, encoding) 34 except: 35 pass 36 return string_data
37