If unsuccessful returns the original as string
776204
public static String encodeString(String str) {
        if (str == null)
            return str;
        if (str.equals("-1"))
            return str;
        try {
            Long lo = new Long(str);
            return encodeLong(lo.longValue());
        } catch (NumberFormatException nfe) {
            // do nothing -- this is expected on zOS, results in string being returned unchanged  242544
        } catch (Throwable th) {
            com.ibm.ws.ffdc.FFDCFilter.processException(th, "com.ibm.ws.session.utils.EncodeCloneID.encodeString", "56", str);
        }
        return str;
    }
531639
def to_string(self, hdr, other):
        """"""
        result = "%s[%s,%s" % (
                hdr, self.get_type(self.type), self.get_clazz(self.clazz))
        if self.unique:
            result += "-unique,"
        else:
            result += ","
        result += self.name
        if other is not None:
            result += ",%s]" % (other)
        else:
            result += "]"
        return result
900577
def get_script_str(self, reset=True):
        """"""
        s = "\n".join(l for l in self._lines)
        if reset:
            self.reset()
        return s
171330
def str_(name):
  """"""
  if isinstance(name, bytes) and not isinstance(name, str):
    return name.decode('utf8')
  else:
    return name
641975
def as_string(self, forsigning=False):
		
		ret = OutBuffer()
		self.serialize(ret, forsigning)
		return ret.getvalue()
533576
def safestr(str_):
    '''  '''
    str_ = str_ or ""
    return "".join(x for x in str_ if x.isalnum())
840941
def to_string(self):
        """"""
        suffix = '%s %s' % (self.type, self.name)
        if self.initial_value:
            suffix += ' = ' + self.initial_value
        return suffix
1088351
def to_str(s, encoding=None, errors='strict'):
    
    encoding = encoding or 'utf-8'

    if is_strlike(s):
        if six.PY2:
            return s.encode(encoding, errors) if isinstance(s, unicode) else s
        else:
            return s.decode(encoding, errors) if isinstance(s, bytes) else s
    else:
        return str(s)
1216480
def to_str(self, s):
        '''
        
        '''
        if s.__class__ != str:
            if not IS_PY3K:
                s = s.encode('utf-8')
            else:
                raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (s, s.__class__))
        return s
635279
def _asString(self, value):
        """"""
        if sys.version_info[0] == 3:
            if isinstance(value, str):
                return value
            elif isinstance(value, bytes):
                return value.decode('utf-8')
        elif sys.version_info[0] == 2:
            return value.encode('ascii')
556429
def string(self, *args):
        
        data = self.bytes(*args)
        if data is not None:
            return data.rstrip(b"\x00").decode('utf-8')
768027
def _to_string(inp: str) -> str:
        
        if '://' in inp:
            req = requests.get(inp)
            if not req.ok:
                raise ValueError(f"Unable to read {inp}")
            return req.text
        else:
            with open(inp) as infile:
                return infile.read()
1212936
def to_string(self, obj):
        
        try:
            converted = [str(element) for element in obj]
            string = ','.join(converted)
        except TypeError:
            # for now this is ok for booleans
            string = str(obj)
        return string
478910
def to_string(self):
        
        if self.major == -1:
            major_str = 'x'
        else:
            major_str = self.major
        if self.minor == -1:
            minor_str = 'x'
        else:
            minor_str = self.minor
        if self.patch == -1:
            patch_str = 'x'
        else:
            patch_str = self.patch
        return '{0}_{1}_{2}'.format(major_str, minor_str, patch_str)
429101
def as_string(self):
        """"""
        if type(self.instruction) is str:
            return self.instruction

        if self.action == "FROM" and not isinstance(self.command, six.string_types):
            extra = "" if self.extra is NotSpecified else " {0}".format(self.extra)
            return "{0} {1}{2}".format(self.action, self.command.from_name, extra)
        else:
            return "{0} {1}".format(self.action, self.command)
850105
def get_string(self):
        
        graph_string = self.graph.to_string()
        graph_string = graph_string.replace('\\N', '\\n')
        return graph_string
137956
def string(self, writesize=None):
        '''
        
        '''
        if not self.finished:
            self.finished = True
            return self.content
        return ''