Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 71d40963b505df4524269198e237b3e3 > files > 569

virtuoso-opensource-doc-6.1.4-2.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head profile="http://internetalchemy.org/2003/02/profile">
  <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" />
  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />
  <meta name="dc.title" content="Function: split_and_decode - Virtuoso Functions Guide" />
  <meta name="dc.subject" content="Function: split_and_decode - Virtuoso Functions Guide" />
  <meta name="dc.creator" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" />
  <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" />
  <link rel="parent" href="functions.html" title="Chapter Contents" />
  <link rel="prev" href="appendixa.html" title="Appendix" />
  <link rel="next" href="functions.html#.html" title="" />
  <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" />
  <link rel="stylesheet" type="text/css" href="doc.css" />
  <link rel="stylesheet" type="text/css" href="/doc/translation.css" />
  <title>Function: split_and_decode - Virtuoso Functions Guide</title>
  <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
  <meta name="author" content="OpenLink Software Documentation Team ;&#10;" />
  <meta name="copyright" content="OpenLink Software, 1999 - 2009" />
  <meta name="keywords" content="" />
  <meta name="GENERATOR" content="OpenLink XSLT Team" />
 </head>
 <body>
  <div id="header">
    <a name="fn_split_and_decode" />
    <img src="../images/misc/logo.jpg" alt="" />
    <h1>22. Virtuoso Functions Guide - split_and_decode</h1>
  </div>
  <div id="navbartop">
   <div>
      <a class="link" href="functions.html">Chapter Contents</a> | <a class="link" href="fn_space.html" title="space">Prev</a> | <a class="link" href="fn_sprintf.html" title="sprintf">Next</a>
   </div>
  </div>
  <div id="currenttoc">
   <form method="post" action="/doc/adv_search.vspx">
    <div class="search">Keyword Search: <br />
        <input type="text" name="q" /> <input type="submit" name="go" value="Go" />
    </div>
   </form>
   <div>
      <a href="http://www.openlinksw.com/">www.openlinksw.com</a>
   </div>
   <div>
      <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a>
   </div>
    <br />
   <div>
      <a href="index.html">Book Home</a>
   </div>
    <br />
   <div>
      <a href="contents.html">Contents</a>
   </div>
   <div>
      <a href="preface.html">Preface</a>
   </div>
    <br />
   <div>
      <a class="selected" href="functions.html">Virtuoso Functions Guide</a>
   </div>
    <br />
   <div>
      <a href="functions.html#admin">Administration</a>
   </div>
   <div>
      <a href="functions.html#aggr">Aggregate Functions</a>
   </div>
   <div>
      <a href="functions.html#array">Array Manipulation</a>
   </div>
   <div>
      <a href="functions.html#bpel">BPEL APIs</a>
   </div>
   <div>
      <a href="functions.html#backup">Backup</a>
   </div>
   <div>
      <a href="functions.html#compression">Compression</a>
   </div>
   <div>
      <a href="functions.html#cursors">Cursor</a>
   </div>
   <div>
      <a href="functions.html#time">Date &amp; Time Manipulation</a>
   </div>
   <div>
      <a href="functions.html#debug">Debug</a>
   </div>
   <div>
      <a href="functions.html#dict">Dictionary Manipulation</a>
   </div>
   <div>
      <a class="selected" href="functions.html#encoding">Encoding &amp; Decoding</a>
   </div>
   <div class="selected">
    <div>
        <a href="fn_encode_base64.html">encode_base64</a>
    </div>
    <div>
        <a class="selected" href="fn_split_and_decode.html">split_and_decode</a>
    </div>
    <div>
        <a href="fn_uudecode.html">uudecode</a>
    </div>
    <div>
        <a href="fn_uuencode.html">uuencode</a>
    </div>
   </div>
   <div>
      <a href="functions.html#file">File Manipulation</a>
   </div>
   <div>
      <a href="functions.html#ft">Free Text</a>
   </div>
   <div>
      <a href="functions.html#hash">Hashing / Cryptographic</a>
   </div>
   <div>
      <a href="functions.html#ldap">LDAP</a>
   </div>
   <div>
      <a href="functions.html#localization">Locale</a>
   </div>
   <div>
      <a href="functions.html#mail">Mail</a>
   </div>
   <div>
      <a href="functions.html#misc">Miscellaneous</a>
   </div>
   <div>
      <a href="functions.html#number">Number</a>
   </div>
   <div>
      <a href="functions.html#phrz">Phrases</a>
   </div>
   <div>
      <a href="functions.html#rdf">RDF data</a>
   </div>
   <div>
      <a href="functions.html#rmt">Remote SQL Data Source</a>
   </div>
   <div>
      <a href="functions.html#repl">Replication</a>
   </div>
   <div>
      <a href="functions.html#soap">SOAP</a>
   </div>
   <div>
      <a href="functions.html#sql">SQL</a>
   </div>
   <div>
      <a href="functions.html#string">String</a>
   </div>
   <div>
      <a href="functions.html#txn">Transaction</a>
   </div>
   <div>
      <a href="functions.html#type">Type Mapping</a>
   </div>
   <div>
      <a href="functions.html#uddi">UDDI</a>
   </div>
   <div>
      <a href="functions.html#udt">User Defined Types &amp; The CLR</a>
   </div>
   <div>
      <a href="functions.html#vad">VAD</a>
   </div>
   <div>
      <a href="functions.html#jvmpl">Virtuoso Java PL API</a>
   </div>
   <div>
      <a href="functions.html#bif">Virtuoso Server Extension Interface (VSEI)</a>
   </div>
   <div>
      <a href="functions.html#ws">Web &amp; Internet</a>
   </div>
   <div>
      <a href="functions.html#xml">XML</a>
   </div>
   <div>
      <a href="functions.html#XPATH">XPATH &amp; XQUERY</a>
   </div>
    <br />
   <div>
      <a href="functionidx.html">Functions Index</a>
   </div>
    <br />
  </div>
  <div id="text">
    <h2>split_and_decode</h2>
    <div class="refpurpose">converts escaped var=val pairs to a vector of strings</div>
    <div class="funcsynopsis">
        <span class="funcdef">vector or string <span class="function">split_and_decode</span>
      </span>
        (<span class="paramdef">in <span class="parameter">coded_str</span> varchar</span>, 
        <span class="paramdefoptional">[in <span class="optional">case_mode</span> integer]</span>, 
        <span class="paramdefoptional">[in <span class="optional">str</span> varchar]</span>);
      </div>
  
  
  
  <div class="refsect1">
      <div class="refsect1title">Description</div>
   <p>split_and_decode converts the escaped var=val pair inputs text to a corresponding vector of
string elements. If the optional third argument is a string of less than three characters, then
does only the decoding (but no splitting) and returns back a string.</p>
   </div>
  <div class="refsect1">
      <div class="refsect1title">Parameters</div>
    <div class="refsect2">
        <span class="refsect2title">coded_str – </span>
      Input string to be converted.</div>
    <div class="refsect2">
        <span class="refsect2title">case_mode – </span>
      This optional second argument, if present should be an integer
   either 0, 1 or 2, which tells whether &quot;variable name&quot;-parts
   (those at the left side of the fourth character given in
   third argument (or = if using the default URL-decoding))
   are converted to UPPERCASE (1), lowercase (2) or left intact
   (0 or when the second argument is not given).
    This avoids all hard-coded limits for the length
   of elements, by scanning the inputs string three times.
   First for the total number of elements (the length of vector
   to allocate), then calculating the length of each string element
   to be allocated, and finally transferring the characters of elements
   to the allocated string elements.
	
</div>
    <div class="refsect2">
        <span class="refsect2title">str – </span>
      If this argument is a string of less than three characters then
      this function will only decode without splitting and will return a string.</div>
  </div>
  <div class="refsect1">
      <div class="refsect1title">Examples</div>
<a name="ex_split_and_decode" />
      <div class="example">
        <div class="exampletitle">Using split_and_decode</div>
<div>
          <pre class="programlisting">
   split_and_decode(&quot;Tulipas=Taloon+kumi=kala&amp;Joka=haisi
		+pahalle&amp;kuin&amp;%E4lymystöporkkana=ilman ruuvausta&quot;,1)
   produces a vector:
   (&quot;TULIPAS&quot; &quot;Taloon kumi=kala&quot; &quot;JOKA&quot; &quot;haisi pahalle&quot; &quot;KUIN&quot; NULL
   &quot;ÄLYMYSTÖPORKKANA&quot; &quot;ilman ruuvausta&quot;)
</pre>
        </div>
  <div>
          <pre class="programlisting">
   split_and_decode(NULL)   =&gt; NULL
   split_and_decode(&quot;&quot;)     =&gt; NULL
   split_and_decode(&quot;A&quot;)    =&gt; (&quot;A&quot; NULL)
   split_and_decode(&quot;A=B&quot;)  =&gt; (&quot;A&quot; &quot;B&quot;)

   split_and_decode(&quot;A&amp;B&quot;)  =&gt; (&quot;A&quot; NULL &quot;B&quot; NULL)
   split_and_decode(&quot;=&quot;)    =&gt; (&quot;&quot; &quot;&quot;)
   split_and_decode(&quot;&amp;&quot;)    =&gt; (&quot;&quot; NULL &quot;&quot; NULL)
   split_and_decode(&quot;&amp;=&quot;)   =&gt; (&quot;&quot; NULL &quot;&quot; &quot;&quot;)
   split_and_decode(&quot;&amp;=&amp;&quot;)  =&gt; (&quot;&quot; NULL &quot;&quot; &quot;&quot; &quot;&quot; NULL)
   split_and_decode(&quot;%&quot;)    =&gt; (&quot;%&quot; NULL)
   split_and_decode(&quot;%%&quot;)   =&gt; (&quot;%&quot; NULL)
   split_and_decode(&quot;%41&quot;)  =&gt; (&quot;A&quot; NULL)
   split_and_decode(&quot;%4&quot;)   =&gt; (&quot;%4&quot; NULL)
   split_and_decode(&quot;%?41&quot;) =&gt; (&quot;%?41&quot; NULL)
</pre>
        </div>
  <p>
   Can also work like Perl&#39;s split function (we define the escape prefix
   and space escape character as NUL-characters, so that they will not be
   encountered at all:
  </p>
  <div>
          <pre class="programlisting">
   split_and_decode(&#39;Un,dos,tres&#39;,0,&#39;\0\0,&#39;) =&gt; (&quot;Un&quot; &quot;dos&quot; &quot;tres&quot;)
   split_and_decode(&quot;Un,dos,tres&quot;,1,&#39;\0\0,&#39;) =&gt; (&quot;UN&quot; &quot;DOS&quot; &quot;TRES&quot;)
   split_and_decode(&quot;Un,dos,tres&quot;,2,&#39;\0\0,&#39;) =&gt; (&quot;un&quot; &quot;dos&quot; &quot;tres&quot;)
</pre>
        </div>
			<p>
   Can also be used as replace and ucase (or lcase) together,
   for example, here we use the comma as space-escape instead of
   element-separator: (not recommended, use replace and ucase instead.
	</p>
			<div>
          <pre class="programlisting">
   split_and_decode(&quot;Un,dos,tres&quot;,0,&#39;\0,&#39;)   =&gt; &quot;Un dos tres&quot;
   split_and_decode(&quot;Un,dos,tres&quot;,1,&#39;\0,&#39;)   =&gt; &quot;UN DOS TRES&quot;
</pre>
        </div>
			<p>
   Can be also used for decoding (some of) MIME-encoded mail-headers:
	</p>
			<div>
          <pre class="programlisting">
   split_and_decode(&#39;=?ISO-8859-1?Q?Tiira_lent=E4=E4_taas?=&#39;,0,&#39;=_&#39;)
   =&gt;  &quot;=?ISO-8859-1?Q?Tiira lentää taas?=&quot;

   split_and_decode(&#39;Message-Id: &lt;199511141036.LAA06462@correo.unet.ar&gt;\n
		From: &quot;=?ISO-8859-1?Q?Jorge_Mo=F1as?=&quot; &lt;jorgem@unet.ar&gt;\n
		To: &quot;Jore Carvajal&quot; &lt;carvajal@wanabee.fr&gt;\nSubject: RE: Um-pah-pah\n
		Date: Wed, 12 Nov 1997 11:28:51 +0100\n
		X-MSMail-Priority: Normal\nX-Priority: 3\n
		X-Mailer: Molosoft Internet Mail 4.70.1161\nMIME-Version: 1.0\n
		Content-Type: text/plain; charset=ISO-8859-1\n
		Content-Transfer-Encoding: 8bit\nX-Mozilla-Status: 0011&#39;,
   1,&#39;=_\n:&#39;);
   =&gt; (&#39;MESSAGE-ID&#39; &#39; &lt;199511141036.LAA06462@correo.unet.ar&gt;&#39;
   &#39;FROM&#39; &#39; &quot;=?ISO-8859-1?Q?Jorge Moñas?=&quot; &lt;jorgem@unet.ar&gt;&#39;
   &#39;TO&#39; &#39; &quot;Jore Carvajal&quot; &lt;carvajal@wanabee.fr&gt;&#39;
   &#39;SUBJECT&#39; &#39; RE: Um-pah-pah&#39;
   &#39;DATE&#39; &#39; Wed, 12 Nov 1997 11:28:51 +0100&#39;
   &#39;X-MSMAIL-PRIORITY&#39; &#39; Normal&#39;
   &#39;X-PRIORITY&#39; &#39; 3&#39;
   &#39;X-MAILER&#39; &#39; Molosoft Internet Mail 4.70.1161&#39;
   &#39;MIME-VERSION&#39; &#39; 1.0&#39;
   &#39;CONTENT-TYPE&#39; &#39; text/plain; charset=ISO-8859-1&#39;
   &#39;CONTENT-TRANSFER-ENCODING&#39; &#39; 8bit&#39;
   &#39;X-MOZILLA-STATUS&#39; &#39; 0011&#39;)
</pre>
        </div>
			<p>
   Same, but let&#39;s use space, not colon as a variable=value separator:
</p>
			<div>
          <pre class="programlisting">
   split_and_decode(&#39;Message-Id: &lt;199511141036.LAA06462@correo.unet.ar&gt;\n
		From: &quot;=?ISO-8859-1?Q?Jorge_Mo=F1as?=&quot; &lt;jorgem@unet.ar&gt;\n
		To: &quot;Jore Carvajal&quot; &lt;carvajal@wanabee.fr&gt;\nSubject: RE: Um-pah-pah\n
		Date: Wed, 12 Nov 1997 11:28:51 +0100\n
		X-MSMail-Priority: Normal\nX-Priority: 3\n
		X-Mailer: Molosoft Internet Mail 4.70.1161\nMIME-Version: 1.0\n
		Content-Type: text/plain; charset=ISO-8859-1\n
		Content-Transfer-Encoding: 8bit\nX-Mozilla-Status: 0011&#39;,
   1,&#39;=_\n &#39;)
   =&gt; (&#39;MESSAGE-ID:&#39; &#39;&lt;199511141036.LAA06462@correo.unet.ar&gt;&#39;
   &#39;FROM:&#39; &#39;&quot;=?ISO-8859-1?Q?Jorge Moñas?=&quot; &lt;jorgem@unet.ar&gt;&#39;
   &#39;TO:&#39; &#39;&quot;Jore Carvajal&quot; &lt;carvajal@wanabee.fr&gt;&#39;
   &#39;SUBJECT:&#39; &#39;RE: Um-pah-pah&#39;
   &#39;DATE:&#39; &#39;Wed, 12 Nov 1997 11:28:51 +0100&#39;
   &#39;X-MSMAIL-PRIORITY:&#39; &#39;Normal&#39;
   &#39;X-PRIORITY:&#39; &#39;3&#39;
   &#39;X-MAILER:&#39; &#39;Molosoft Internet Mail 4.70.1161&#39;
   &#39;MIME-VERSION:&#39; &#39;1.0&#39;
   &#39;CONTENT-TYPE:&#39; &#39;text/plain; charset=ISO-8859-1&#39;
   &#39;CONTENT-TRANSFER-ENCODING:&#39; &#39;8bit&#39;
   &#39;X-MOZILLA-STATUS:&#39; &#39;0011&#39;)
</pre>
        </div>
			<p>
   Of course this approach does not work with multiline headers, except
   somewhat kludgously.
   If the lines are separated by CR+LF, there is left one trailing
   CR at the end of each value part string.
</p>
</div>

	</div>
</div>
  <div id="footer">
    <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div>
   <div id="validation">
    <a href="http://validator.w3.org/check/referer">
        <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" />
    </a>
    <a href="http://jigsaw.w3.org/css-validator/">
        <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" />
    </a>
   </div>
  </div>
 </body>
</html>