00001 # Copyright (C) 2008-2009 Mark Hanegraaff 00002 # 00003 # This program is free software: you can redistribute it and/or modify 00004 # it under the terms of the GNU General Public License as published by 00005 # the Free Software Foundation, either version 3 of the License, or 00006 # (at your option) any later version. 00007 # 00008 # This program is distributed in the hope that it will be useful, 00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 # GNU General Public License for more details. 00012 # 00013 # You should have received a copy of the GNU General Public License 00014 # along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 00016 00017 from objects.logic.common.logger import logger 00018 import string 00019 00020 00021 00022 ## A class containing various conversion related functions 00023 class conversionUtil(): 00024 def __init__(self): 00025 pass 00026 00027 ## Removes all non printable characters from a string, and replaces them with the supplied parameter. 00028 # @param str Dirty string 00029 # @param replaceWith Printable character used to replace all non printable in the supplied string 00030 # @return Clean String 00031 def removeNonASCIICharaters(str, replaceWith): 00032 00033 retVal = "" 00034 00035 for char in str: 00036 if char in string.printable: 00037 retVal += char 00038 else: 00039 retVal += replaceWith 00040 00041 return retVal 00042 00043 00044 00045 removeNonASCIICharaters = staticmethod(removeNonASCIICharaters) 00046 00047
1.5.8