Assuming the source file has an even number of quotes, shouldn't replacing them with curly quotes be as simple as
Code:
intag = False
inquote = False
for i, chr in enumerate(data):
if chr == '<':
intag = True
elif chr == '>'
intag = False
elif not intag and chr == '"':
if inquote:
data[i] = right curly quote
inquote = False
else:
data[i] = left curly quote
inquote = True
Or is there something about curly quotes I'm missing?