Exemple #1
0
#!/usr/bin/env python
import warnings as _warnings
_warnings.resetwarnings()
_warnings.filterwarnings('error')

from tdi.tools import javascript

x = javascript.escape_string(u'\xe9--"\'\\-----]]></script>')
print type(x).__name__, x

x = javascript.escape_string(u'\xe9---"\'\\----]]></script>', inlined=False)
print type(x).__name__, x

x = javascript.escape_string('\xe9--"\'\\-----]]></script>')
print type(x).__name__, x

x = javascript.escape_string('\xe9---"\'\\----]]></script>', inlined=False)
print type(x).__name__, x

try:
    x = javascript.escape_string('\xe9--"\'\\-----]]></script>',
        encoding='utf-8'
    )
except UnicodeError:
    print "UnicodeError - OK"

try:
    x = javascript.escape_string('\xe9--"\'\\-----]]></script>',
        inlined=False, encoding='utf-8'
    )
except UnicodeError:
Exemple #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import warnings as _warnings
_warnings.resetwarnings()
_warnings.filterwarnings('error')

# BEGIN INCLUDE
from tdi.tools import javascript

print javascript.escape_string(u"\n - é - € - \U0001d51e")