+
+ // encodeLineBreaks encodes line breaks with an escape sequence.
+ // We do this, because our strings are attribute values inside XML tags.
+ //
+ // If we don't, we lose line breaks after importing data because
+ // XML parser converts line breaks into a single white character.
+ //
+ // TODO: investigate whether we need to encode \t, etc.
+ private function encodeLineBreaks($source) {
+ $result = htmlspecialchars($source);
+ $result = str_replace ("\n", ' ', $result);
+ $result = str_replace ("\r", ' ', $result);
+ return $result;
+ }