title: Encode String in XQuery
body: <p>Wrote a function in my web application based on eXist-db to export some xml elements to csv with XQuery. Everything works fine but I have some umlauts like ü, ä or ß in my elements which are displayed the wrong way in my csv. I tried to encode the content by using fn:normalize-unicode but this is not working.
  Here is a minimalized example of my code snippet:</p>
  
  <pre><code>let $input =
      &lt;root&gt;
          &lt;number&gt;1234&lt;/number&gt;
          &lt;name&gt;Aufmaß&lt;/name&gt;
      &lt;/root&gt;
  
  let $csv := string-join(
      for $ta in $input
          return concat($ta/number/text(), fn:normalize-unicode($ta/name/text())))
  
  let $csv-ueber-string := concat($csv-ueber, string-join($massnahmen, $nl))
  
  let $set-content-type := response:set-header('Content-Type', 'text/csv')
  let $set-accept := response:set-header('Accept', 'text/csv')
  let $set-file-name := response:set-header('Content-Disposition', 'attachment; filename="export.csv"')
  
  return response:stream($csv, '')
  </code></pre>