Module Ustring.Op


module Op: sig .. end
Sub module Ustring.Op is containing Unicode versions of several functions available in the Pervasives module, as well as operators and functions for simple string creation and manipulation (for example string concatenation operator ^., ustring equality operator =. and string creation us"string"). Use it by opening the op module open Ustring.Op Do not open module Ustring directly, since there is a risk for name conflicts.

type ustring 
Unicode string type
val (^.) : ustring -> ustring -> ustring
Fast infix string concatenation operator. Equivalent to function Ustring.fast_append. Compared to function append and standard string concatenation operator ^, function fast_append do not allocate new memory or create a new fresh string. Instead, the concatenation is internally stored as a tree, making the operation constant time. When the string is later used by some function in module Ustring, the internal tree representation will be automatically collapsed to a plain string. Note that in contrary to append, this function do not create a fresh new string directly. Hence, if the sub strings are shared and modified in place, this string will also be updated. To make sure that the result string is unique, call function Ustring.copy. It is recommended to use ^. instead of ^..
val (^..) : ustring -> ustring -> ustring
Infix string concatenation operator. Equivalent to function Ustring.append. Note that this function is always creating a new fresh string after append. For performance demanding application, function fast_append or operator ^. are recommended instead.
val (=.) : ustring -> ustring -> bool
Safe structural equality operator for ustrings. For performance reason, an ustring instance can have different representations internally for the same string. Hence, use of standard equality operator = is unsafe. Always use this operator instead. This operator is equivalent to function Ustring.equal
val (<>.) : ustring -> ustring -> bool
Safe structural inequality operator for ustrings. This operator is equivalent to function Ustring.not_equal. See also operator =.
val us : string -> ustring
Creates a ustring from a Latin-1 encoded OCaml string. This function is an alias function for Ustring.from_latin1. The purpose is to make it a simple short-cut for writing inline Unicode strings in programs, e.g., (us"This is a Unicode string") defines a ustring.
val uc : char -> Ustring.uchar
Creates a uchar from a Latin-1 encoded char.

Module Pervasives's functions


The following section defines the Unicode version of several functions available in the Pervasives module.
val ustring_of_bool : bool -> ustring
Returns the string representation ("true" or "false") of the boolean argument.
val bool_of_ustring : ustring -> bool
Expression bool_of_ustring s returns "true" if s has value true or false if s has value "false". Raises Invalid_argument "bool_of_ustring" if the string is neither "true" nor "false".
val ustring_of_int : int -> ustring
Returns the string representation of an integer in decimal.
val int_of_ustring : ustring -> int
Expression int_of_ustring s converts string s to an integer value. By default, the string is assumed to be encoded in decimal form, e.g. 1342 or -3212. If the string starts with 0x or 0X it is interpreted as hexadecimal. If it starts with 0o or 0O it is treated as octal and if starting with 0b or 0B as binary. If the string has not a valid representation or if its size exceeds the range of type int, exception Failure "int_of_ustring" is raised.
val ustring_of_float : float -> ustring
Returns the string representation of a floating-point number.
val float_of_ustring : ustring -> float
Converts the ustring representation of a floating-point number, e.g., 123.21, -0.1231, or 3.212e-12 to a floating-point value. Raises Failure "float_of_ustring" if the string do not represent a valid floating-point number.
val uprint_char : Ustring.uchar -> unit
Prints a uchar to the standard output. Converts to UTF-8 encoding.
val uprint_string : ustring -> unit
Prints a ustring to the standard output. Converts to UTF-8 encoding
val uprint_int : int -> unit
Prints an integer i decimal form to the standard output. Same as pervasives function print_int
val uprint_float : float -> unit
Prints a floating-point number in decimal form to the standard output. Same as pervasives function print_float
val uprint_endline : ustring -> unit
Prints a ustring to the standard output, followed by a newline character and flush of the standard output. Converts to UTF-8 encoding.
val uprint_newline : unit -> unit
Prints a new line and flushes the standard output. Same as pervasives function print_newline

Other functions

val uprint_bool : bool -> unit
Prints the string representation of an boolean to the standard output.