Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4556078
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:18:57+00:00 2026-05-21T17:18:57+00:00

I have a UTF-8 xml file littered with codes like ÃÂ&xA7; for a cedilla

  • 0

I have a UTF-8 xml file littered with codes like ÃÂ&xA7; for a cedilla etc
I have written the snippet below to remove or replace with acceptable values
1. Is there a better way to do this?
2. When I run this on some large XML files (>50MB) I may get Out of memory errors. If there is no better way how can I optimize it avoid OOM errors?

<cffile 
    action="read"
    file="#ExpandPath('./xs.xml')#"
    variable="myfile"/>

<cfset myfile =ReReplace(myfile,'&##xC2;&##x2013;','.','all')/>
<cfset myfile =ReReplace(myfile,'&##xC2;&##x2019;','''','all')/>
<cfset myfile =ReReplace(myfile,'&##xC2;&##x201D;','"','all')/>

<cfset myfile =ReReplace(myfile,'&##xC3;&##x192;&##xC2;&##xA7;','c','all')/>
<cfset myfile =ReReplace(myfile,'&##xC3;&##xA7;','c','all')/>
<cfset myfile =ReReplace(myfile,'&##xC3;&##xA9;','e','all')/>
<cfset myfile =ReReplace(myfile,'&##xC3;&##x201A;&##xC2;&##x2022;','(*)','all')/>
<cfset myfile =ReReplace(myfile,'&##xC3;&##x192;&##xC2;&##x201A;\?','(*)','all')/>
<cfset myfile =ReReplace(myfile,'&##xC3;&##x201A;&##xC2;&##xB7;','-','all')/>
<cfset myfile =ReReplace(myfile,'&##xC3;&##x201A;&##xC2;&##x2018;','''','all')/>
<cfset myfile =ReReplace(myfile,' &##xC3;&##x201A;&##xC2;&##x201C;',' "','all')/>

<cfset myfile =ReReplace(myfile,'&##xE2;&##x20AC;&##x201C;','-','all')/>
<cfset myfile =ReReplace(myfile,'&##xE2;&##x20AC;&##x2122;','''','all')/>
<cfset myfile =ReReplace(myfile,' &##xE2;&##x20AC;&##x153;',' "','all')/>
<cfset myfile =ReReplace(myfile,'&##xE2;&##x20AC;&##x153;','-','all')/>
<cfset myfile =ReReplace(myfile,'&##xE2;&##x20AC;&##xFFFD; ','" ','all')/>
<cfset myfile =ReReplace(myfile,'&##xE2;&##x20AC;&##xFFFD;','-','all')/>
<cfset myfile =ReReplace(myfile,'&##xE2;&##x201E;&##xA2;','(TM)','all')/>
<cfset myfile =ReReplace(myfile,'&##xE2;&##x20AC;&##xA2;','(*)','all')/>

<cfset myfile =ReReplace(myfile,'&##xEF;&##x201A;&##xA7;','(*)','all')/>

<cfset myfile =ReReplace(myfile,'(&##[^;]*;)','','all')/>

<cffile action="write"
     file="#ExpandPath('./xs_new.xml')#"
     output="#myfile#"/>

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:18:58+00:00Added an answer on May 21, 2026 at 5:18 pm

    Use ColdFusion’s file functions to work on one line at a time, instead of reading the entire thing into memory:

    <cfscript>
    myfile = FileOpen(ExpandPath('./xs.xml'), "read"); 
    myNewFile = FileOpen(ExpandPath('./xs_new.xml'), "write"); 
    
    while(NOT FileisEOF(myfile)) { 
        line = FileReadLine(myfile); // read line 
    
        line = ReReplace(line,'&##xC2;&##x2013;','.','all');
        line = ReReplace(line,'&##xC2;&##x2019;','''','all');
        line = ReReplace(line,'&##xC2;&##x201D;','"','all');
    
        line = ReReplace(line,'&##xC3;&##x192;&##xC2;&##xA7;','c','all');
        line = ReReplace(line,'&##xC3;&##xA7;','c','all');
        line = ReReplace(line,'&##xC3;&##xA9;','e','all');
        line = ReReplace(line,'&##xC3;&##x201A;&##xC2;&##x2022;','(*)','all');
        line = ReReplace(line,'&##xC3;&##x192;&##xC2;&##x201A;\?','(*)','all');
        line = ReReplace(line,'&##xC3;&##x201A;&##xC2;&##xB7;','-','all');
        line = ReReplace(line,'&##xC3;&##x201A;&##xC2;&##x2018;','''','all');
        line = ReReplace(line,' &##xC3;&##x201A;&##xC2;&##x201C;',' "','all');
    
        line = ReReplace(line,'&##xE2;&##x20AC;&##x201C;','-','all');
        line = ReReplace(line,'&##xE2;&##x20AC;&##x2122;','''','all');
        line = ReReplace(line,' &##xE2;&##x20AC;&##x153;',' "','all');
        line = ReReplace(line,'&##xE2;&##x20AC;&##x153;','-','all');
        line = ReReplace(line,'&##xE2;&##x20AC;&##xFFFD; ','" ','all');
        line = ReReplace(line,'&##xE2;&##x20AC;&##xFFFD;','-','all');
        line = ReReplace(line,'&##xE2;&##x201E;&##xA2;','(TM)','all');
        line = ReReplace(line,'&##xE2;&##x20AC;&##xA2;','(*)','all');
    
        line = ReReplace(line,'&##xEF;&##x201A;&##xA7;','(*)','all');
    
        line = ReReplace(line,'(&##[^;]*;)','','all');  
    
        fileWrite(line);
    } 
    
    FileClose(myfile); 
    FileClose(myNewFile);
    </cfscript>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have a xml file like this <?xml version=1.0 encoding=UTF-8?> <gallery > <gallerydata> <galleryname>
I have XML-file with settings like this <?xml version=1.0 encoding=utf-8 ?> <configuration> <configSections> <sectionGroup
I have xml file like this <?xml version=1.0 encoding=UTF-8?> <specification xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=file://Desktop/normal.xsd> <university> <refstr>bdvl_te_skrm_stc</refstr>
I have an XML file that looks like this: <?xml version=1.0? encoding=UTF-8 standalone=no?> <dir
I have a XML file like this: <?xml version='1.0' encoding='utf-8'?> <sitegroup name = 'healthcare'>
I have an xml file like this: <?xml version=1.0 encoding=UTF-8?> <todo> <list><item>first</item><item>second</item></list> <list><item>first</item><item>second</item></list> </todo>
I have an XML file like this: <?xml version=1.0 encoding=utf-8?> <RootElement> <Achild> ..... </Achild>
I have a XML file like this : <?xml version=1.0 encoding=UTF-8 standalone=no ?> <user>
I have a XML File like that <?xml version=1.0 encoding=utf-8 ?> <Configurations> <EmailConfiguration> <userName>xxxx</userName>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.