1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
// Copyright 2017 The UNIC Project Developers. // // See the COPYRIGHT file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![forbid(unsafe_code)] //! # UNIC: Unicode and Internationalization Crates for Rust //! //! The `unic` super-crate (this) is a collection of all UNIC components, providing //! an easy way of access to all functionalities, when all or many are needed, //! instead of importing components one-by-one, and ensuring all components //! imported are compatible in algorithms and consistent data-wise. //! //! ## Components //! //! - [`ucd`](/unic-ucd): Unicode Character Database. //! //! - [`bidi`](/unic-bidi): Unicode Bidirectional Algorithm (USA\#9). //! //! - [`normal`](/unic-normal): Unicode Normalization Forms (USA\#15). //! //! - [`idna`](/unic-idna): Unicode IDNA Compatibility Processing (UTS\#46). //! //! //! ## A Basic Example //! //! ```rust //! use unic::bidi::BidiInfo; //! use unic::normal::StrNormalForm; //! use unic::ucd::{Age, BidiClass, CharAge, CharBidiClass, StrBidiClass, UnicodeVersion, is_cased}; //! use unic::ucd::normal::compose; //! //! #[cfg_attr(rustfmt, rustfmt_skip)] //! #[test] //! fn test_sample() { //! //! // Age //! //! assert_eq!(Age::of('A').unwrap().actual(), UnicodeVersion { major: 1, minor: 1, micro: 0 }); //! assert_eq!(Age::of('\u{A0000}'), None); //! assert_eq!( //! Age::of('\u{10FFFF}').unwrap().actual(), //! UnicodeVersion { major: 2, minor: 0, micro: 0 } //! ); //! //! if let Some(age) = '🦊'.age() { //! assert_eq!(age.actual().major, 9); //! assert_eq!(age.actual().minor, 0); //! assert_eq!(age.actual().micro, 0); //! } //! //! // Bidi //! //! let text = concat![ //! "א", //! "ב", //! "ג", //! "a", //! "b", //! "c", //! ]; //! //! assert!(!text.has_bidi_explicit()); //! assert!(text.has_rtl()); //! assert!(text.has_ltr()); //! //! assert_eq!(text.chars().nth(0).unwrap().bidi_class(), BidiClass::RightToLeft); //! assert!(!text.chars().nth(0).unwrap().is_ltr()); //! assert!(text.chars().nth(0).unwrap().is_rtl()); //! //! assert_eq!(text.chars().nth(3).unwrap().bidi_class(), BidiClass::LeftToRight); //! assert!(text.chars().nth(3).unwrap().is_ltr()); //! assert!(!text.chars().nth(3).unwrap().is_rtl()); //! //! let bidi_info = BidiInfo::new(text, None); //! assert_eq!(bidi_info.paragraphs.len(), 1); //! //! let para = &bidi_info.paragraphs[0]; //! assert_eq!(para.level.number(), 1); //! assert_eq!(para.level.is_rtl(), true); //! //! let line = para.range.clone(); //! let display = bidi_info.reorder_line(para, line); //! assert_eq!( //! display, //! concat![ //! "a", //! "b", //! "c", //! "ג", //! "ב", //! "א", //! ] //! ); //! //! // Case //! //! assert_eq!(is_cased('A'), true); //! assert_eq!(is_cased('א'), false); //! //! // Normalization //! //! assert_eq!(compose('A', '\u{030A}'), Some('Å')); //! //! let s = "ÅΩ"; //! let c = s.nfc().collect::<String>(); //! assert_eq!(c, "ÅΩ"); //! //! } //! ``` pub extern crate unic_bidi as bidi; pub extern crate unic_char as char; pub extern crate unic_idna as idna; pub extern crate unic_normal as normal; pub extern crate unic_ucd as ucd; /// The [Unicode version](http://www.unicode.org/versions/) of data pub use ucd::UNICODE_VERSION;