Name
[2.0]
string-to-codepoints()
Converts a string into a sequence of Unicode codepoints.
Syntax
xs:integer*string-to-codepoints(
xs:string?
)
Inputs
An xs:string
.
Output
A sequence of xs:integer
s, each of which represents a
Unicode codepoint. If the input string is of zero length or is the
empty sequence, the empty sequence is returned.
Defined in
XQuery 1.0 and XPath 2.0 Functions and Operators section 7.2, “Functions to Assemble and Disassemble Strings.”
Example
Here’s a short stylesheet that converts strings into sequences of integers:
<?xml version="1.0" encoding="UTF-8"?> <!-- string-to-codepoints.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>
Tests of the string-to-codepoints() </xsl:text> <xsl:text>function:
</xsl:text> <xsl:text>
 string-to-codepoints('Lily') = </xsl:text> <xsl:value-of select="string-to-codepoints('Lily')" separator=", " /> <xsl:text>
 string-to-codepoints('Straße') = </xsl:text> <xsl:value-of select="string-to-codepoints('Straße')" separator=", "/> </xsl:template> </xsl:stylesheet>
The stylesheet generates these results:
Tests of the string-to-codepoints() function: string-to-codepoints('Lily') = 76, 105, 108, 121 string-to-codepoints('Straße') = 83, 116, 114, 97, 223, 101
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.