文字列の反転
Posted feedbacks - XSLT
sjisっていっても多分内部ではutf-8で処理するんでしょうけど...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <?xml version="1.0" encoding="sjis"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:my="uri:ja.doukaku.org:my-functions"
exclude-result-prefixes="my"
>
<xsl:output method="text" encoding="sjis" />
<xsl:template match="/" >
<xsl:value-of select="my:reverse_string('Hello')" />
<xsl:text>
</xsl:text>
<xsl:value-of select="my:reverse_string('こんにちは')" />
<xsl:text>
</xsl:text>
<xsl:value-of select="my:reverse_string('濁点(だくてん)')" />
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:function name="my:reverse_string" as="xs:string">
<xsl:param name="s" as="xs:string" />
<xsl:value-of select="fn:codepoints-to-string(fn:reverse(fn:string-to-codepoints($s)))" />
</xsl:function>
</xsl:stylesheet>
|

にしお
#3414()
Rating0/2=0.00
サンプル入出力
>>> print reverse_string("Hello") olleH >>> print reverse_string("こんにちは") はちにんこ >>> print reverse_string("濁点(だくてん)") )んてくだ(点濁[ reply ]