]> git.lizzy.rs Git - rust.git/blob - src/libunicode/lib.rs
Merge pull request #20510 from tshepang/patch-6
[rust.git] / src / libunicode / lib.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! # The Unicode Library
12 //!
13 //! Unicode-intensive functions for `char` and `str` types.
14 //!
15 //! This crate provides a collection of Unicode-related functionality,
16 //! including decompositions, conversions, etc., and provides traits
17 //! implementing these functions for the `char` and `str` types.
18 //!
19 //! The functionality included here is only that which is necessary to
20 //! provide for basic string-related manipulations. This crate does not
21 //! (yet) aim to provide a full set of Unicode tables.
22
23 #![crate_name = "unicode"]
24 #![experimental]
25 #![crate_type = "rlib"]
26 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
27        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
28        html_root_url = "http://doc.rust-lang.org/nightly/",
29        html_playground_url = "http://play.rust-lang.org/")]
30 #![no_std]
31 #![feature(globs, macro_rules, slicing_syntax, unboxed_closures)]
32 #![feature(associated_types)]
33
34 extern crate core;
35
36 // regex module
37 pub use tables::regex;
38
39 mod normalize;
40 mod tables;
41 mod u_char;
42 mod u_str;
43
44 // re-export char so that std et al see it correctly
45 /// Character manipulation (`char` type, Unicode Scalar Value)
46 ///
47 /// This module  provides the `Char` and `UnicodeChar` traits, as well as their
48 /// implementation for the primitive `char` type, in order to allow basic character
49 /// manipulation.
50 ///
51 /// A `char` actually represents a
52 /// *[Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value)*,
53 /// as it can contain any Unicode code point except high-surrogate and
54 /// low-surrogate code points.
55 ///
56 /// As such, only values in the ranges \[0x0,0xD7FF\] and \[0xE000,0x10FFFF\]
57 /// (inclusive) are allowed. A `char` can always be safely cast to a `u32`;
58 /// however the converse is not always true due to the above range limits
59 /// and, as such, should be performed via the `from_u32` function..
60 pub mod char {
61     pub use core::char::{MAX, from_u32};
62     pub use core::char::{from_digit};
63     pub use core::char::Char;
64
65     pub use normalize::{decompose_canonical, decompose_compatible, compose};
66
67     pub use tables::normalization::canonical_combining_class;
68     pub use tables::UNICODE_VERSION;
69
70     pub use u_char::UnicodeChar;
71 }
72
73 pub mod str {
74     pub use u_str::{UnicodeStr, Words, Graphemes, GraphemeIndices};
75     pub use u_str::{utf8_char_width, is_utf16, Utf16Items, Utf16Item};
76     pub use u_str::{utf16_items, Utf16Encoder};
77 }
78
79 // this lets us use #[derive(..)]
80 mod std {
81     pub use core::clone;
82     pub use core::cmp;
83     pub use core::fmt;
84 }