use oxide_regexp::unicode::case::convert_case_with_limit;
use oxide_regexp::unicode::{CodeUnitBuf, MAX_STRING_LEN};
pub(crate) fn to_lower(text: &[u16]) -> Option<Vec<u16>> {
convert(text, false)
}
pub(crate) fn to_upper(text: &[u16]) -> Option<Vec<u16>> {
convert(text, true)
}
fn convert(text: &[u16], upper: bool) -> Option<Vec<u16>> {
match convert_case_with_limit(text, upper, MAX_STRING_LEN).ok()? {
CodeUnitBuf::Latin1(bytes) => Some(bytes.into_iter().map(u16::from).collect()),
CodeUnitBuf::Utf16(units) => Some(units),
}
}