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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top