2021-08-28 14:40:14 +00:00
|
|
|
//! Provides UCS2 string types for usage in AVM1 and AVM2.
|
|
|
|
//!
|
|
|
|
//! Internally, these types are represeted by a sequence of 1-byte or 2-bytes (wide) code units,
|
|
|
|
//! that may contains null bytes or unpaired surrogates.
|
|
|
|
//!
|
|
|
|
//! To match Flash behavior, the string length is limited to 2³¹-1 code units;
|
|
|
|
//! any attempt to create a longer string will panic.
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod common;
|
|
|
|
|
2021-09-12 10:20:51 +00:00
|
|
|
mod avm;
|
2021-09-01 12:50:34 +00:00
|
|
|
mod buf;
|
2021-08-28 14:40:14 +00:00
|
|
|
mod ops;
|
2021-09-28 15:48:14 +00:00
|
|
|
mod parse;
|
2021-09-17 19:12:11 +00:00
|
|
|
mod pattern;
|
2021-11-05 22:32:43 +00:00
|
|
|
mod ptr;
|
2021-08-23 11:11:50 +00:00
|
|
|
mod tables;
|
|
|
|
pub mod utils;
|
2021-09-12 10:20:51 +00:00
|
|
|
|
2021-11-05 22:32:43 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|
|
|
|
|
|
|
|
pub use ptr::{WStr, MAX_STRING_LEN};
|
2021-08-28 14:40:14 +00:00
|
|
|
|
2021-09-12 10:20:51 +00:00
|
|
|
pub use avm::AvmString;
|
2021-09-01 12:50:34 +00:00
|
|
|
pub use buf::WString;
|
2021-11-05 22:32:43 +00:00
|
|
|
pub use common::Units;
|
2021-10-04 23:27:13 +00:00
|
|
|
pub use ops::{CharIndices, Chars, Iter, Split, WStrToUtf8};
|
2021-09-28 15:48:14 +00:00
|
|
|
pub use parse::{FromWStr, Integer};
|
2021-09-17 19:12:11 +00:00
|
|
|
pub use pattern::Pattern;
|
2021-11-05 22:32:43 +00:00
|
|
|
|
|
|
|
use std::borrow::Borrow;
|
2021-08-28 14:40:14 +00:00
|
|
|
|
|
|
|
use common::panic_on_invalid_length;
|
2021-10-02 22:28:32 +00:00
|
|
|
|
|
|
|
/// Flattens a slice of strings, placing `sep` as a separator between each.
|
|
|
|
#[inline]
|
2021-11-05 22:32:43 +00:00
|
|
|
pub fn join<E: Borrow<WStr>, S: Borrow<WStr>>(elems: &[E], sep: &S) -> WString {
|
2021-10-02 22:28:32 +00:00
|
|
|
crate::string::ops::str_join(elems, sep.borrow())
|
|
|
|
}
|