XML technologies / XSLT / XSLT and XPath functions / Alphabetical XSLT and XPath reference / string-to-codepoints

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

fn:string-to-codepoints

Category:

String functions – codepoint conversion

Origin:

XPath 2.0

Return value:

A sequence of xs:integer integers; the Unicode Codepoint values which represent the characters of the input string.

Call/Arguments:

fn:string-to-codepoints($inputString)

$inputString:

Obligatory. A xs:string string whose characters shall be converted to a sequence of Unicode Codepoint values.

Purpose of use:

The fn:string-to-codepoints() function is the counterpart of the fn:codepoints-to-string() function. It returns a sequence of integer values each of which corresponds to a Unicode Codepoint and which represent the individual characters of which the input string consists of. If the input string is the empty string, the function returns the empty sequence.

A possible problem results from the Unicode specification which, under certain circumstances, assigns several different codepoints (or a sequence of codepoints) to identical abstract characters. Therefore, the conversion does not necessarily have to be unique. For example, the Å character is representable by the codepoint 0197 (»latin capital letter a with ring above«) or the codepoint 8491 (»angstrom sign«).

Remark: The »Unicode Codespace« which can be used for the definition of codepoints includes the integer range from 0 to 10FFFF (hexadecimal), which means 0 to 1.114.111 (decimal).

Example – application on an input string:

fn:string-to-codepoints('Hello World!')

results in the sequence: (72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33).

In this example, each character of the input string is represented by the decimal number of its Unicode Codepoint, for example the H (Unicode U+0072) by 72.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:string-to-codepoints($arg as xs:string?) as xs:integer*

   

 

 

 

back to top