[][src]Trait kanaria::char::UCSChar

pub trait UCSChar: Debug + Sized + Default + Copy + Ord + Eq {
    const NULL: Self;

    fn is_in_range(&self, low: u32, high: u32) -> bool;
fn is_contains(&self, search: &[u32]) -> bool;
fn is_match(&self, target: u32) -> bool;
fn is_surrogate(&self) -> bool;
fn is_high_surrogate(&self) -> bool;
fn is_low_surrogate(&self) -> bool;
fn is_null(&self) -> bool;
fn addition(&self, value: u32) -> Self;
fn subtraction(&self, value: u32) -> Self;
fn as_scalar(&self) -> u32;
fn from_scalar<T>(value: T) -> Self
    where
        T: UCSChar
; }

Associated Constants

const NULL: Self

NULLを表します。

Loading content...

Required methods

fn is_in_range(&self, low: u32, high: u32) -> bool

対象がlow以上high以下かどうかを判定します。

Examples

use kanaria::UCSChar;
use kanaria::constants::*;

// (0x0041 >= 0x0041) && (0x0041 <= 0x005A)
let true_case = 'A'.is_in_range(NARROW_ASCII_LATIN_UPPER_CASE_A, NARROW_ASCII_LATIN_UPPER_CASE_Z);
assert_eq!(true_case, true);

// (0x0061 >= 0x0041) && (0x0061 <= 0x005A)
let false_case = 'a'.is_in_range(NARROW_ASCII_LATIN_UPPER_CASE_A, NARROW_ASCII_LATIN_UPPER_CASE_Z);
assert_eq!(false_case, false);

fn is_contains(&self, search: &[u32]) -> bool

searchの中に対象を含むかどうかを判定します。

Examples

use kanaria::UCSChar;
use kanaria::constants::*;

let true_case = 'A'.is_contains(&[NARROW_ASCII_LATIN_UPPER_CASE_A, NARROW_ASCII_LATIN_UPPER_CASE_B, NARROW_ASCII_LATIN_UPPER_CASE_C]);
assert_eq!(true_case, true);

let false_case = 'D'.is_contains(&[NARROW_ASCII_LATIN_UPPER_CASE_A, NARROW_ASCII_LATIN_UPPER_CASE_B, NARROW_ASCII_LATIN_UPPER_CASE_C]);
assert_eq!(false_case, false);

fn is_match(&self, target: u32) -> bool

targetと対象が同値であるかどうかを判定します。

Examples

use kanaria::UCSChar;
use kanaria::constants::*;

let true_case = 'A'.is_match(NARROW_ASCII_LATIN_UPPER_CASE_A);
assert_eq!(true_case, true);

let false_case = 'A'.is_match(NARROW_ASCII_LATIN_LOWER_CASE_A);
assert_eq!(false_case, false);

fn is_surrogate(&self) -> bool

サロゲートペアであるかどうかを判定します。

Examples

use kanaria::UCSChar;

// 𩸽(ほっけ)の上位サロゲート
assert_eq!(0xD867u16.is_surrogate(), true);

// 𩸽(ほっけ)の下位サロゲート
assert_eq!(0xDE3Du16.is_surrogate(), true);

// ひらがなの「あ」
assert_eq!(0x3042u16.is_surrogate(), false);

fn is_high_surrogate(&self) -> bool

上位サロゲートであるかどうかを判定します。

Examples

use kanaria::UCSChar;

// 𩸽(ほっけ)の上位サロゲート
assert_eq!(0xD867u16.is_high_surrogate(), true);

// 𩸽(ほっけ)の下位サロゲート
assert_eq!(0xDE3Du16.is_high_surrogate(), false);

// ひらがなの「あ」
assert_eq!(0x3042u16.is_high_surrogate(), false);

fn is_low_surrogate(&self) -> bool

下位サロゲートであるかどうかを判定します。

Examples

use kanaria::UCSChar;

// 𩸽(ほっけ)の上位サロゲート
assert_eq!(0xD867u16.is_low_surrogate(), false);

// 𩸽(ほっけ)の下位サロゲート
assert_eq!(0xDE3Du16.is_low_surrogate(), true);

// ひらがなの「あ」
assert_eq!(0x3042u16.is_low_surrogate(), false);

fn is_null(&self) -> bool

null文字であるかどうかを判定します。

Examples

use kanaria::UCSChar;

assert_eq!(char::NULL.is_null(), true);
assert_eq!('a'.is_null(), false);

fn addition(&self, value: u32) -> Self

対象にvalueの値を加算した文字を取得します。

Examples

use kanaria::UCSChar;
use kanaria::constants::*;

let ret = 'あ'.addition(0x0060);
assert_eq!(ret, 'ア');

fn subtraction(&self, value: u32) -> Self

対象からvalueの値を減算した文字を取得します。

Examples

use kanaria::UCSChar;
use kanaria::constants::*;

let ret = 'ア'.subtraction(0x0060);
assert_eq!(ret, 'あ');

fn as_scalar(&self) -> u32

値をUnicodeスカラ値に変換します。

Examples

use kanaria::UCSChar;
use kanaria::constants::*;

let ret = 'A'.as_scalar();
assert_eq!(ret, NARROW_ASCII_LATIN_UPPER_CASE_A);

fn from_scalar<T>(value: T) -> Self where
    T: UCSChar

Unicodeスカラ値から値を取り込みます。

Examples

use kanaria::UCSChar;
use kanaria::constants::*;

let ret = char::from_scalar(NARROW_ASCII_LATIN_UPPER_CASE_A);
assert_eq!(ret, 'A');
Loading content...

Implementations on Foreign Types

impl UCSChar for char[src]

impl UCSChar for u16[src]

impl UCSChar for u32[src]

Loading content...

Implementors

Loading content...