I have an off topic question to propose at this list.
I'm working with eXist to store terminology record that contains terms even in arabic or chinese language.
With the UTF-8 coding i have no problem in this xml files, but i have to export this kind of record in text files to
import it in another proprietary application.
I do this with an xslt transformation, but when i import this text files the arabic and chinese terms are all transformed in
unrecognized characters and rendered by a series of ? .
I know that a text file is not encoded in UTF-8 but is in a machine dependant coding, but how i can mantain the original
character sequence even for the arabic and chinese terms ?

This is my xslt:

<?xml version=" 1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="text" version=" 2.0" indent="no" encoding="UTF-8"/>
    <xsl:strip-space elements="*"/>
    <xsl:variable name="newline">
        <xsl:text>&#13;&#10;</xsl:text>
    </xsl:variable>
    <xsl:template match="/items">
        <xsl:for-each select="termEntry">
            <xsl:apply-templates select="."/>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="termEntry">
        <xsl:text>**</xsl:text>
        <xsl:for-each select="descrip">
            <xsl:apply-templates select="."/>
        </xsl:for-each>
        <xsl:for-each select="langSet">
            <xsl:sort select="@xml:lang"/>
            <xsl:apply-templates select="."/>
        </xsl:for-each>
        <xsl:text>**</xsl:text>
        <xsl:value-of select="$newline"/>
    </xsl:template>
    <xsl:template match="descrip">
        <xsl:if test="node()!=''">
            <xsl:text>&lt;</xsl:text>
            <xsl:value-of select="@type"/>
            <xsl:text>&gt;</xsl:text>
            <xsl:apply-templates/>
            <xsl:value-of select="$newline"/>
        </xsl:if>
    </xsl:template>
    <xsl:template match="langSet">
        <xsl:for-each select="tig">
            <xsl:sort select="term"/>
            <xsl:apply-templates select="term">
                <xsl:with-param name="lang" select=" parent::langSet/@xml:lang"/>
            </xsl:apply-templates>
            <xsl:apply-templates select="descrip"/>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="term">
        <xsl:param name="lang"/>
        <xsl:choose>

                        [ ... ]

            <xsl:when test="$lang = 'en'">
                <xsl:text>&lt;English&gt;</xsl:text>
            </xsl:when>
            <xsl:when test="$lang = 'ar'">
                <xsl:text>&lt;Arabic&gt;</xsl:text>
            </xsl:when>
            <xsl:when test="$lang = 'zh'">
                <xsl:text>&lt;Chinese&gt;</xsl:text>
            </xsl:when>
        </xsl:choose>
        <xsl:apply-templates/>
        <xsl:value-of select="$newline"/>
    </xsl:template>
</xsl:stylesheet>


Thanks for any help,

Giuseppe Corrarello.