BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
vis Namespace Reference

Functions

def vis
 
def unvis
 

Variables

list __all__
 
int VIS_OCTAL = 0x0001
 Constants from bsd/vis.h.
 
int VIS_CSTYLE = 0x0002
 
int VIS_SP = 0x0004
 
int VIS_TAB = 0x0008
 
int VIS_NL = 0x0010
 
 VIS_WHITE = VIS_SP|VIS_TAB|VIS_NL
 
int VIS_SAFE = 0x0020
 
int VIS_NOSLASH = 0x0040
 
int VIS_HTTP1808 = 0x0080
 
int VIS_HTTPSTYLE = 0x0080
 
int VIS_MIMESTYLE = 0x0100
 
int VIS_HTTP1866 = 0x0200
 
int VIS_NOESCAPE = 0x0400
 
int VIS_GLOB = 0x1000
 
tuple _libbsd = CDLL(find_library('bsd'))
 Import libbsd/vis functions.
 
 _strvis = _libbsd.strvis
 
 _strunvis = _libbsd.strunvis
 

Detailed Description

vis.py
======

Ctypes based module to access libbsd's strvis & strunvis functions.

The `vis` function is the equivalent of strvis.
The `unvis` function is the equivalent of strunvis.
All functions accept unicode string as input and return a unicode string.

Constants:
----------

* to select alternate encoding format
  `VIS_OCTAL`:      use octal \ddd format
  `VIS_CSTYLE`:     use \[nrft0..] where appropiate

* to alter set of characters encoded
  (default is to encode all non-graphic except space, tab, and newline).
  `VIS_SP`:         also encode space
  `VIS_TAB`:        also encode tab
  `VIS_NL`:         also encode newline
  `VIS_WHITE`:      same as (VIS_SP | VIS_TAB | VIS_NL)
  `VIS_SAFE`:       only encode "unsafe" characters

* other
  `VIS_NOSLASH`:    inhibit printing '\'
  `VIS_HTTP1808`:   http-style escape % hex hex
  `VIS_HTTPSTYLE`:  http-style escape % hex hex
  `VIS_MIMESTYLE`:  mime-style escape = HEX HEX
  `VIS_HTTP1866`:   http-style &#num; or &string;
  `VIS_NOESCAPE`:   don't decode `\'
  `VIS_GLOB`:       encode glob(3) magic characters

:Authors:
- ju1ius (http://github.com/ju1ius)
:Version: 1
:Date: 2014-01-05

Function Documentation

def vis.unvis (   src)
Decodes a string encoded by vis.

C definition:
int strunvis(char *dst, char *src);
def vis.vis (   src,
  flags = VIS_WHITE 
)
Encodes the string `src` into libbsd's vis encoding.
`flags` must be one of the VIS_* constants

C definition:
int strvis(char *dst, char *src, int flags);

Variable Documentation

list vis.__all__
Initial value:
1 = [
2  'vis', 'unvis',
3  'VIS_OCTAL', 'VIS_CSTYLE',
4  'VIS_SP', 'VIS_TAB', 'VIS_NL', 'VIS_WHITE', 'VIS_SAFE',
5  'VIS_NOSLASH', 'VIS_HTTP1808', 'VIS_HTTPSTYLE', 'VIS_MIMESTYLE',
6  'VIS_HTTP1866', 'VIS_NOESCAPE', 'VIS_GLOB'
7 ]