]> git.lizzy.rs Git - rust.git/blob - src/libunicode/lib.rs
0ac569b9c8ea3d6e2226c0db20d4aeb0ddeb1f46
[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 #![unstable(feature = "unicode")]
25 #![feature(staged_api)]
26 #![staged_api]
27 #![crate_type = "rlib"]
28 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
29        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
30        html_root_url = "http://doc.rust-lang.org/nightly/",
31        html_playground_url = "http://play.rust-lang.org/")]
32 #![feature(no_std)]
33 #![no_std]
34 #![feature(slicing_syntax)]
35 #![feature(int_uint)]
36 #![feature(core)]
37
38 extern crate core;
39
40 // regex module
41 pub use tables::regex;
42
43 mod normalize;
44 mod tables;
45 mod u_char;
46 mod u_str;
47
48 // re-export char so that std et al see it correctly
49 /// Character manipulation (`char` type, Unicode Scalar Value)
50 ///
51 /// This module provides the `CharExt` trait, as well as its
52 /// implementation for the primitive `char` type, in order to allow
53 /// basic character manipulation.
54 ///
55 /// A `char` actually represents a
56 /// *[Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value)*,
57 /// as it can contain any Unicode code point except high-surrogate and
58 /// low-surrogate code points.
59 ///
60 /// As such, only values in the ranges \[0x0,0xD7FF\] and \[0xE000,0x10FFFF\]
61 /// (inclusive) are allowed. A `char` can always be safely cast to a `u32`;
62 /// however the converse is not always true due to the above range limits
63 /// and, as such, should be performed via the `from_u32` function.
64 #[stable(feature = "rust1", since = "1.0.0")]
65 pub mod char {
66     pub use core::char::{MAX, from_u32, from_digit};
67
68     pub use normalize::{decompose_canonical, decompose_compatible, compose};
69
70     pub use tables::normalization::canonical_combining_class;
71     pub use tables::UNICODE_VERSION;
72
73     pub use u_char::CharExt;
74 }
75
76 pub mod str {
77     pub use u_str::{UnicodeStr, Words, Graphemes, GraphemeIndices};
78     pub use u_str::{utf8_char_width, is_utf16, Utf16Items, Utf16Item};
79     pub use u_str::{utf16_items, Utf16Encoder};
80 }
81
82 // NOTE: remove after next snapshot
83 // this lets us use #[derive(..)]
84 #[cfg(stage0)]
85 mod std {
86     pub use core::clone;
87     pub use core::cmp;
88     pub use core::fmt;
89     pub use core::marker;
90     // for-loops
91     pub use core::iter;
92     pub use core::option;
93 }