mono-api-string.html 3.2 KB

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