2009-03-17 Jb Evain <jbevain@novell.com>
[mono.git] / docs / sources / mono-api-string.html
1 <h2>Strings</h2>
2
3         <p>Strings representation inside the Mono runtime.
4
5 <h3>Synopsis</h3>
6
7         <div class="header">
8 #include &lt;metadata/object.h&gt;
9
10 typedef struct {
11         MonoObject object;
12         gint32 length;
13         gunichar2 chars [0];
14 } MonoString;
15
16 @API_IDX@
17         </div>
18
19         <p>All of the operations on strings are done on pointers to
20         MonoString objects, like this:
21
22         <div class="code">
23         MonoString *hello = mono_string_new (mono_domain_get (), "hello, world");
24         </div>
25
26         <p>Strings are bound to a particular application domain, which
27         is why it is necessary to pass a MonoDomain argument as the
28         first parameter to all the constructor functions. 
29
30         <p>Typically, you want to create the strings on the current
31         application domain, so a call to <tt>mono_domain_get()</tt> is
32         sufficient.
33         
34 <h3>Constructors</h3>
35         
36 <h4><a name="api:mono_string_new">mono_string_new</a></h4>
37 <h4><a name="api:mono_string_new_len">mono_string_new_len</a></h4>
38 <h4><a name="api:mono_string_new_size">mono_string_new_size</a></h4>
39 <h4><a name="api:mono_string_new_utf16">mono_string_new_utf16</a></h4>
40 <h4><a name="api:mono_string_from_utf16">mono_string_from_utf16</a></h4>
41
42 <h3>Conversions</h3>
43
44 <h4><a name="api:mono_string_to_byvalstr">mono_string_to_byvalstr</a></h4>
45 <h4><a name="api:mono_string_to_byvalwstr">mono_string_to_byvalwstr</a></h4>
46 <h4><a name="api:mono_string_to_utf16">mono_string_to_utf16</a></h4>
47 <h4><a name="api:mono_string_to_utf8">mono_string_to_utf8</a></h4>
48 <h4><a name="api:mono_string_utf16_to_builder">mono_string_utf16_to_builder</a></h4>
49 <h4><a name="api:mono_string_utf8_to_builder">mono_string_utf8_to_builder</a></h4>
50
51 <h3>Methods</h3>
52
53 <h4><a name="api:mono_string_equal">mono_string_equal</a></h4> 
54 <h4><a name="api:mono_string_hash">mono_string_hash</a></h4> 
55 <h4><a name="api:mono_string_intern">mono_string_intern</a></h4>
56 <h4><a name="api:mono_string_is_interned">mono_string_is_interned</a></h4>
57 <h4><a name="api:mono_string_new_wrapper">mono_string_new_wrapper</a></h4>
58 <h4><a name="api:mono_string_chars">mono_string_chars</a></h4>
59 <h4><a name="api:mono_string_length">mono_string_length</a></h4>
60
61
62 <h3>String Builders</h3>
63
64         <p>These routines are used to work with the managed types
65         <tt>System.Text.StringBuilder</tt>.
66         
67 <h4><a name="api:mono_string_builder_to_utf16">mono_string_builder_to_utf16</a></h4>
68 <h4><a name="api:mono_string_builder_to_utf8">mono_string_builder_to_utf8</a></h4>
69
70 <h3>Other Encodings</h3>
71
72         <p>These routines are used when coping with strings that come
73         from Mono's environment, and might be encoded in one or more
74         of the external encodings.
75
76         <p>For example, some file systems might historically contain a
77         mix of file names with both old and new encodings, typically
78         UTF8 for new files, and the old files would be encoded in an 8
79         bit character set (ISO-8859-1 for example).
80         
81         <p>These routines try a number of encodings, those specified
82         in the <tt>MONO_ENCODINGS</tt> environment variable and return
83         unicode strings that can be used internally.
84
85         <p>See the mono(1) man page for more details.
86         
87 <h4><a name="api:mono_unicode_from_external">mono_unicode_from_external</a></h4>
88 <h4><a name="api:mono_unicode_to_external">mono_unicode_to_external</a></h4>
89 <h4><a name="api:mono_utf8_from_external">mono_utf8_from_external</a></h4>