Escape non standard characters to windows 1252 character set

Primary tabs

I have an xml that has non standard characters and I would like to transform it with xslt  so that those characters render in the format  &#nnn here is what I have so far any help appreciated 




<!--?xml version="1.0"?-->
<xsl:transform version="1.0" xmlns:xsl="">
<xsl:output encoding="Windows-1252" indent="yes" omit-xml-declaration="yes" method="xml">
>  <xsl:template match="/Recordset">
  <xsl:template match="*|@*">
      <xsl:apply-templates select="@*">



128 € euro sign
129    NOT USED
130 ‚ single low-9 quotation mark
131 ƒ Latin small letter f with hook
132 „ double low-9 quotation mark
133 … horizontal ellipsis
134 † dagger
135 ‡ double dagger
136 ˆ modifier letter circumflex accent
137 ‰ per mille sign
138 Š Latin capital letter S with caron
139 ‹ single left-pointing angle quotation mark
140 ΠLatin capital ligature OE
141    NOT USED
142 Ž Latin capital letter Z with caron
143    NOT USED
144    NOT USED
145 ‘ left single quotation mark
146 ’ right single quotation mark
147 “ left double quotation mark
148 ” right double quotation mark
149 • bullet
150 – en dash
151 — em dash
152 ˜ small tilde
153 ™ trade mark sign
154 š Latin small letter s with caron
155 › single right-pointing angle quotation mark
156 œ Latin small ligature oe
157    NOT USED
158 ž Latin small letter z with caron
159 Ÿ Latin capital letter Y with diaeresis
160 no-break space 



My hunch is that XSLT is not the right tool for the job, but it's not clear to me what you're trying to do. What is the input encoding, what is the desired output encoding, and what do you mean by non-standard characters? Are these characters that don't exist in the output encoding?

So the input is Windows-1252, and the output is Windows-1252 in which certain characters are mapped to their numerical escape sequence? You could do this with XSLT 2.0 using character maps.

Given this input (presented here as UTF-8 for visibility on the forum):

<?xml version="1.0"?>
• coffee €5,• tea €4

This stylesheet will escape the bullets and euro signs:

<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="">
  <xsl:character-map name="a">
    <xsl:output-character character="€" string="&amp;#128;"/>
    <xsl:output-character character="•" string="&amp;#149;"/>
  <xsl:output encoding="Windows-1252" indent="yes" use-character-maps="a"/>
  <xsl:template match="/">
      <xsl:value-of select="/Recordset"/>


<?xml version="1.0" encoding="Windows-1252"?>
&#149; coffee &#128;5,&#149; tea &#128;4

Is it one node or known nodes which can contain characters for escaping?

If so custom datatype may be a better solution.

@Eduard Lebedyuk  No it is not  a known node what I am trying to do is pull those characters and  pass them to  $TRANSLATE($SYSTEM.Encryption.Base64Encode(streamString),$C(10,13))' as part of a document I need to convert to a pdf but have tried all the encodings I could use from utf -8 to the windows 1252 and I get an error like so 

ERROR <Ens>ErrException: <ILLEGAL VALUE>zEncodeStream+18  @' set encString = $TRANSLATE($SYSTEM.Encryption.Base64Encode(streamString),$C(10,13))' any ways to get around the base 64 encoding

Still not sure I'm entirely on the same page wrt the goal, but $translate is to replace individual characters with other individual characters (so 1 by 1). If you're looking for a proper function in ObjectScript, take a look at $zconvert(), which supports HTML and XML-escaping.