utf8 Module

This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
Created by Vladyslav Kozlovskyy (Ukraine) <dbdevelop©gmail.com>
for Web2py project

Utilities and class for UTF8 strings managing

class gluon.utf8.Utf8[source]

Bases: str

Class for utf8 string storing and manipulations

The base presupposition of this class usage is: “ALL strings in the application are either of utf-8 or unicode type, even when simple str type is used. UTF-8 is only a “packed” version of unicode, so Utf-8 and unicode strings are interchangeable.”

CAUTION! This class is slower than str/unicode! Do NOT use it inside intensive loops. Simply decode string(s) to unicode before loop and encode it back to utf-8 string(s) after intensive calculation.

You can see the benefit of this class in doctests() below

capitalize()[source]
center(length)[source]
count(sub, start=0, end=None)[source]
decode(encoding='utf-8', errors='strict')[source]
encode(encoding, errors='strict')[source]
endswith(prefix, start=0, end=None)[source]
expandtabs(tabsize=8)[source]
find(sub, start=None, end=None)[source]
format(*args, **kwargs)[source]
index(string)[source]
isalnum()[source]
isalpha()[source]
isdigit()[source]
islower()[source]
isspace()[source]
istitle()[source]
isupper()[source]
join(iter)[source]
ljust(width, fillchar=' ')[source]
lower()[source]
lstrip(chars=None)[source]
partition(sep)[source]
replace(old, new, count=-1)[source]
rfind(sub, start=None, end=None)[source]
rindex(string)[source]
rjust(width, fillchar=' ')[source]
rpartition(sep)[source]
rsplit(sep=None, maxsplit=-1)[source]
rstrip(chars=None)[source]
split(sep=None, maxsplit=-1)[source]
splitlines(keepends=False)[source]
startswith(prefix, start=0, end=None)[source]
strip(chars=None)[source]
swapcase()[source]
title()[source]
translate(table, deletechars='')[source]
upper()[source]
zfill(length)[source]