~ubuntu-branches/ubuntu/karmic/ocamlnet/karmic

« back to all changes in this revision

Viewing changes to doc/html/refman/Netencoding.Html.html

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Zacchiroli
  • Date: 2005-04-15 08:47:01 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050415084701-3sxqut7h5ftfm3jp
Tags: 1.0-1
* New upstream release
* Urgency set to medium (rational: bug fix/consolidation release)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<link rel="stylesheet" href="style.css" type="text/css">
 
4
<link rel="Start" href="index.html">
 
5
<link rel="previous" href="Netencoding.Url.html">
 
6
<link rel="Up" href="Netencoding.html">
 
7
<link title="Index of types" rel=Appendix href="index_types.html">
 
8
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
 
9
<link title="Index of values" rel=Appendix href="index_values.html">
 
10
<link title="Index of class methods" rel=Appendix href="index_methods.html">
 
11
<link title="Index of classes" rel=Appendix href="index_classes.html">
 
12
<link title="Index of class types" rel=Appendix href="index_class_types.html">
 
13
<link title="Index of modules" rel=Appendix href="index_modules.html">
 
14
<link title="Netconversion" rel="Chapter" href="Netconversion.html">
 
15
<link title="Netchannels" rel="Chapter" href="Netchannels.html">
 
16
<link title="Netstream" rel="Chapter" href="Netstream.html">
 
17
<link title="Mimestring" rel="Chapter" href="Mimestring.html">
 
18
<link title="Netmime" rel="Chapter" href="Netmime.html">
 
19
<link title="Netsendmail" rel="Chapter" href="Netsendmail.html">
 
20
<link title="Neturl" rel="Chapter" href="Neturl.html">
 
21
<link title="Netaddress" rel="Chapter" href="Netaddress.html">
 
22
<link title="Netbuffer" rel="Chapter" href="Netbuffer.html">
 
23
<link title="Netdate" rel="Chapter" href="Netdate.html">
 
24
<link title="Netencoding" rel="Chapter" href="Netencoding.html">
 
25
<link title="Netulex" rel="Chapter" href="Netulex.html">
 
26
<link title="Netaccel" rel="Chapter" href="Netaccel.html">
 
27
<link title="Netaccel_link" rel="Chapter" href="Netaccel_link.html">
 
28
<link title="Nethtml" rel="Chapter" href="Nethtml.html">
 
29
<link title="Netstring_str" rel="Chapter" href="Netstring_str.html">
 
30
<link title="Netstring_pcre" rel="Chapter" href="Netstring_pcre.html">
 
31
<link title="Netstring_mt" rel="Chapter" href="Netstring_mt.html">
 
32
<link title="Netmappings" rel="Chapter" href="Netmappings.html">
 
33
<link title="Netaux" rel="Chapter" href="Netaux.html">
 
34
<link title="Netcgi_env" rel="Chapter" href="Netcgi_env.html">
 
35
<link title="Netcgi_types" rel="Chapter" href="Netcgi_types.html">
 
36
<link title="Netcgi" rel="Chapter" href="Netcgi.html">
 
37
<link title="Netcgi_jserv" rel="Chapter" href="Netcgi_jserv.html">
 
38
<link title="Netcgi_jserv_ajp12" rel="Chapter" href="Netcgi_jserv_ajp12.html">
 
39
<link title="Netcgi_jserv_app" rel="Chapter" href="Netcgi_jserv_app.html">
 
40
<link title="Netcgi_fcgi_10" rel="Chapter" href="Netcgi_fcgi_10.html">
 
41
<link title="Netcgi_fcgi" rel="Chapter" href="Netcgi_fcgi.html">
 
42
<link title="Netpop" rel="Chapter" href="Netpop.html"><title>OcamlNet Reference Manual : Netencoding.Html</title>
 
43
</head>
 
44
<body>
 
45
<div class="navbar"><a href="Netencoding.Url.html">Previous</a>
 
46
&nbsp;<a href="Netencoding.html">Up</a>
 
47
&nbsp;</div>
 
48
<center><h1>Module <a href="type_Netencoding.Html.html">Netencoding.Html</a></h1></center>
 
49
<br>
 
50
<pre><span class="keyword">module</span> Html: <code class="code">sig</code> <a href="Netencoding.Html.html">..</a> <code class="code">end</code></pre><hr width="100%">
 
51
<br>
 
52
Encodes characters that need protection by converting them to
 
53
 entity references. E.g. <code class="code">"&lt;"</code> is converted to <code class="code">"&amp;lt;"</code>.
 
54
 As the entities may be named, there is a dependency on the character
 
55
 set.<br>
 
56
<br>
 
57
Legacy functions:<br>
 
58
<pre><span class="keyword">val</span> <a name="VALencode_from_latin1"></a>encode_from_latin1 : <code class="type">string -> string</code></pre><pre><span class="keyword">val</span> <a name="VALdecode_to_latin1"></a>decode_to_latin1 : <code class="type">string -> string</code></pre><br>
 
59
These functions have a more general interface and should be preferred
 
60
 in new programs.<br>
 
61
<pre><span class="keyword">val</span> <a name="VALunsafe_chars_html4"></a>unsafe_chars_html4 : <code class="type">string</code></pre><div class="info">
 
62
The string contains '&lt;', '&gt;', '"', '&amp;' and the control characters
 
63
 0-8, 11-12, 14-31, 127.<br>
 
64
</div>
 
65
<pre><span class="keyword">val</span> <a name="VALencode"></a>encode : <code class="type">in_enc:<a href="Netconversion.html#TYPEencoding">Netconversion.encoding</a> -><br>       ?out_enc:<a href="Netconversion.html#TYPEencoding">Netconversion.encoding</a> -><br>       ?prefer_name:bool -> ?unsafe_chars:string -> unit -> string -> string</code></pre><div class="info">
 
66
The input string that is encoded as <code class="code">in_enc</code> is recoded to 
 
67
 <code class="code">out_enc</code>, and the following characters are encoded as HTML
 
68
 entity (<code class="code">&amp;name;</code> or <code class="code">&amp;#num;</code>):<ul>
 
69
<li>The ASCII characters contained in <code class="code">unsafe_chars</code></li>
 
70
<li>The characters that cannot be represented in <code class="code">out_enc</code>. By
 
71
   default (<code class="code">out_enc=`Enc_usascii</code>), only ASCII characters can be
 
72
   represented, and thus all code points &gt;= 128 are encoded as
 
73
   HTML entities. If you pass <code class="code">out_enc=`Enc_utf8</code>, all characters
 
74
   can be represented.</li>
 
75
</ul>
 
76
 
 
77
 For example, the string <code class="code">"(a&lt;b) &amp; (c&gt;d)"</code> is encoded as
 
78
 <code class="code">"(a&amp;lt;b) &amp;amp; (c&amp;gt;d)"</code>.
 
79
<p>
 
80
 
 
81
 It is required that <code class="code">out_enc</code> is an ASCII-compatible encoding.
 
82
<p>
 
83
 
 
84
 The option <code class="code">prefer_name</code> selects whether named entities (e.g. <code class="code">&amp;lt;</code>)
 
85
 or numeric entities (e.g. <code class="code">&amp;#60;</code>) are prefered.
 
86
<p>
 
87
 
 
88
 The efficiency of the function can be improved when the same encoding
 
89
 is applied to several strings. Create a specialized encoding function
 
90
 by passing all arguments up to the unit argument, and apply this
 
91
 function several times. For example:
 
92
 <pre><code class="code">
 
93
     let my_enc = encode ~in_enc:`Enc_utf8 () in
 
94
     let s1' = my_enc s1 in
 
95
     let s2' = my_enc s2 in ...
 
96
 </code></pre><br>
 
97
</div>
 
98
<pre><span class="keyword">type</span> <a name="TYPEentity_set"></a><code class="type"></code>entity_set = <code class="type">[ `Empty | `Html | `Xml ]</code> </pre>
 
99
 
 
100
<pre><span class="keyword">val</span> <a name="VALdecode"></a>decode : <code class="type">in_enc:<a href="Netconversion.html#TYPEencoding">Netconversion.encoding</a> -><br>       out_enc:<a href="Netconversion.html#TYPEencoding">Netconversion.encoding</a> -><br>       ?lookup:(string -> string) -><br>       ?subst:(int -> string) -><br>       ?entity_base:<a href="Netencoding.Html.html#TYPEentity_set">entity_set</a> -> unit -> string -> string</code></pre><div class="info">
 
101
The input string is recoded from <code class="code">in_enc</code> to <code class="code">out_enc</code>, and HTML
 
102
 entities (<code class="code">&amp;name;</code> or <code class="code">&amp;#num;</code>) are resolved. The input encoding 
 
103
 <code class="code">in_enc</code> must be ASCII-compatible.
 
104
<p>
 
105
 
 
106
 By default, the function knows all entities defined for HTML 4 (this
 
107
 can be changed using <code class="code">entity_base</code>, see below). If other
 
108
 entities occur, the function <code class="code">lookup</code> is called and the name of
 
109
 the entity is passed as input string to the function. It is
 
110
 expected that <code class="code">lookup</code> returns the value of the entity, and that this
 
111
 value is already encoded as <code class="code">out_enc</code>.
 
112
 By default, <code class="code">lookup</code> raises a <code class="code">Failure</code> exception.
 
113
<p>
 
114
 
 
115
 If a character cannot be represented in the output encoding,
 
116
 the function <code class="code">subst</code> is called. <code class="code">subst</code> must return a substitute
 
117
 string for the character.
 
118
 By default, <code class="code">subst</code> raises a <code class="code">Failure</code> exception.
 
119
<p>
 
120
 
 
121
 The option <code class="code">entity_base</code> determines which set of entities are
 
122
 considered as the known entities that can be decoded without
 
123
 help by the <code class="code">lookup</code> function: <code class="code">`Html</code> selects all entities defined
 
124
 for HTML 4, <code class="code">`Xml</code> selects only <code class="code">&amp;lt;</code>, <code class="code">&amp;gt;</code>, <code class="code">&amp;amp;</code>, <code class="code">&amp;quot;</code>,
 
125
 and <code class="code">&amp;apos;</code>,
 
126
 and <code class="code">`Empty</code> selects the empty set (i.e. <code class="code">lookup</code> is always called).<br>
 
127
</div>
 
128
</body></html>
 
 
b'\\ No newline at end of file'