June 2008
Intermediate to advanced
986 pages
27h 8m
English
[2.0]
string-to-codepoints()
Converts a string into a sequence of Unicode codepoints.
xs:integer*string-to-codepoints(xs:string?)
An xs:string.
A sequence of xs:integers, 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.
XQuery 1.0 and XPath 2.0 Functions and Operators section 7.2, “Functions to Assemble and Disassemble Strings.”
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, 101Read now
Unlock full access