Pyjo.String.Unicode - Unicode string

import Pyjo.String.Unicode

# Manipulate String.Unicode
string = Pyjo.String.Unicode.new('foo_bar_baz')
print(string.camelize())

# Chain methods
string = Pyjo.String.Unicode.new('foo_bar_baz').quote()
string = string.unquote().encode('utf-8').b64_encode('')
print(string.decode('ascii'))

# Use the alternative constructor
from Pyjo.String.Unicode import u
string = u('foobarbaz').camelize('').say()

Pyjo.String.Unicode is a container for unicode strings that provides a more friendly API for many of the functions in Pyjo.Util.

It also inherits all methods from either unicode (Python 2.x) or str (Python 3.x).

Classes

class Pyjo.String.Unicode.Pyjo_String_Unicode

Pyjo.String.Unicode inherits all methods from either unicode (Python 2.x) or str (Python 3.x) and implements the following new ones.

__weakref__

list of weak references to the object (if defined)

encode(charset='utf-8')
string = string.encode()
string = string.encode('iso-8859-1')

Encode unicode string, defaults to utf-8, and return new Pyjo.String.Bytes object.

string.trim().quote().encode().say()
html_unescape()
string = string.html_unescape()

Unescape all HTML entities in unicode string with Pyjo.Util.html_unescape().

b('<html>').html_unescape().url_escape().say()
classmethod new(value=u'', charset='utf-8')
string = Pyjo.String.Unicode.new('test123')

Construct a new Pyjo.String.Unicode object.

say(**kwargs)
string = string.say()
string = string.say(file=sys.stderr, end='', flush=True)

Print unicode string to handle and append a newline, defaults to sys.stdout.

to_bytes(charset='utf-8')
bstring = string.to_bytes()
bstring = string.to_bytes(charset)

Turn unicode string into a bytes string.

to_str(charset='utf-8')
string = string.to_str()

Turn unicode string into a string: on Python 2.x into bytes string, on Python 3.x into unicode string.

to_unicode(charset='utf-8')
ustring = string.to_unicode()
ustring = string.to_unicode(charset)

Turn unicode string into an unicode string.

trim()
string = string.trim()

Trim whitespace characters from both ends of bytestring with Pyjo.Util.trim().

xml_escape()
string = string.xml_escape()

Escape only the characters &, <, >, " and ' in unicode string with Pyjo.Util.xml_escape().

Pyjo.String.Unicode.object

alias of Pyjo_String_Unicode

Pyjo.String.Unicode.u(value=u'', charset='utf-8')
string = u('test123')

Construct a new Pyjo.String.Unicode object.