Dashboard
PHP:
8.3.33
OS:
Linux
User:
letter7
/
/
usr
/
share
/
oracle-cloud-agent
/
plugins
/
osms
/
osms
📤 Upload
📝 New File
📁 New Folder
Close
Editing: i18n.py
# Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.org/licenses/UPL. from sys import version_info try: PY3 = version_info.major >= 3 except AttributeError: PY3 = False def ustr(obj): # converts object to unicode like object if PY3: # python3 if isinstance(obj, str): return obj else: return str(obj, 'utf8', errors='ignore') else: # python2 if isinstance(obj, unicode): return obj return unicode(obj, 'utf8', 'ignore') def bstr(obj): # converts object to bytes like object if PY3: # python3 if isinstance(obj, bytes): return obj else: return bytes(obj, 'utf8', errors='ignore') else: # python2 if isinstance(obj, str): return obj return str(obj.encode('utf8', 'ignore')) def sstr(obj): # converts object to string if PY3: # python3 if isinstance(obj, str): return obj else: return str(obj, 'utf8', errors='ignore') else: # python2 if isinstance(obj, str): return obj return str(obj.encode('utf8', 'ignore')) def idn_puny_to_unicode(hostname): """ Convert Internationalized domain name from Punycode (RFC3492) to Unicode """ if hostname is None: return None else: hostname = bstr(hostname) return hostname.decode('idna') def idn_ascii_to_puny(hostname): """ Convert domain name to Punycode (RFC3492). Hostname can be instance of string or Unicode """ if hostname is None: return None else: hostname = ustr(hostname) return hostname.encode('idna')
Save
Cancel