String replace

Hi!
I want to replace “bad characters” in a text string received from an XML document but the replaced text seems to be undefined inside the for loop.

ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]for[/COLOR] [COLOR=#000000]([/COLOR] [COLOR=#000000]**var**[/COLOR] i:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]0[/COLOR]; i < l; i++ [COLOR=#000000])[/COLOR]

[COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]String[/COLOR].[COLOR=#0000FF]prototype[/COLOR].[COLOR=#000080]replace[/COLOR] = [COLOR=#000000]function[/COLOR][COLOR=#000000]([/COLOR]s, z[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR] [COLOR=#0000FF]return[/COLOR] [COLOR=#0000FF]unescape[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#000000]}[/COLOR];
cl.[COLOR=#000080]txt_text[/COLOR].[COLOR=#0000FF]html[/COLOR] = [COLOR=#000000]true[/COLOR];
cl.[COLOR=#000080]txt_text[/COLOR].[COLOR=#0000FF]htmlText[/COLOR] = [COLOR=#0000FF]text[/COLOR].[COLOR=#000080]replace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“å”[/COLOR], [COLOR=#FF0000]“å”[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]