How to encode html and xml tag datas with standard python modules?

D

DurumDara

Hi !

Have the python standard mod. lib. a html/xml encoder functions/procedures ?

like this:

def ToSafeHTM(Text):
s=ToHuStrSafe(Text)
l=[]
for c in s:
b=ord(c)
if c=="\n":
c="<br>"
else:
if b<32 or b>127 or c in ['<','>','"',';','&','@','%','#']:
c="&#%03d;"%b
l.append(c)
s="".join(l)
return s

Thanx for help:
dd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top