pub fn check<T, U>(v1: T, v2: U) -> Result<RbEncoding, Error>where
T: EncodingCapable,
U: EncodingCapable,
Expand description
Returns the common encoding between v1
and v2
, or Err
.
Returns Err
if there is no common compatible encoding.
See also compatible
.
§Examples
use magnus::{encoding, prelude::*, RString};
let a = RString::new("a");
let b = RString::new("b");
assert!(a.enc_get() == encoding::Index::utf8());
b.enc_set(encoding::Index::usascii()).unwrap();
assert_eq!(encoding::check(a, b).unwrap().name(), "UTF-8");