title: Stripping non-ASCII characters from large string
body: <p>Once or twice a month, one of our Peoplesoft batch processes is erroring out. It usually runs alright on the second try, indicating to me that the problem could be environmental. However, since the issue involves a 23M string, I'd like to investigate other possibilities than increasing the heap size.</p>
  
  <p>The current Peoplesoft code looks like this, trimmed down:</p>
  
  <pre><code>Local JavaObject &amp;jString_student;
  Component XmlDoc &amp;student_xmlDoc;
  Local string &amp;xmlStr_email;
  
  &amp;jString_student = CreateJavaObject("java.lang.String", &amp;student_xmlDoc.GenFormattedXmlString());
  &amp;xmlStr_email = &amp;jString_email.replaceAll("^\x20-\x7F\x0a\x0d]", "");
  </code></pre>
  
  <p>Short and sweet, right? For smaller files, it would be. I had the thought that I could leave the results of GenFormattedXmlString() as a regular string, use Split to create an array, and process each line independently. I'm worried that that would hurt performance, though, since I don't have a good sense of how much more time it would take to process half a million small strings instead of one large one. (I would have to do the CreateJavaObject for each line, right?)</p>
  
  <p>Also, is there a straight-PS way to do this, and avoid the problem that way? Thanks.</p>