pub type Latin1JsStringBuilder = JsStringBuilder<u8>;Expand description
Latin1 encoded JsStringBuilder
§Warning
If you are not sure the characters that will be added and don’t want to preprocess them,
use CommonJsStringBuilder instead.
§Examples
use boa_string::Latin1JsStringBuilder;
let mut s = Latin1JsStringBuilder::new();
s.push(b'x');
s.extend_from_slice(&[b'1', b'2', b'3']);
s.extend([b'1', b'2', b'3']);
let js_string = s.build();Aliased Type§
pub struct Latin1JsStringBuilder { /* private fields */ }Implementations§
Source§impl Latin1JsStringBuilder
impl Latin1JsStringBuilder
Sourcepub fn build(self) -> Option<JsString>
pub fn build(self) -> Option<JsString>
Builds a JsString if the current instance is strictly ASCII.
When the string contains characters outside the ASCII range, it cannot be determined
whether the encoding is Latin1 or others. Therefore, this method only returns a
valid JsString when the instance is entirely ASCII. If any non-ASCII characters
are present, it returns None to avoid ambiguity in encoding.
If the caller is certain that the string is encoded in Latin1,
build_as_latin1 can be used to avoid the ASCII check.
Sourcepub unsafe fn build_as_latin1(self) -> JsString
pub unsafe fn build_as_latin1(self) -> JsString
Builds JsString from Latin1JsStringBuilder, assume that the inner data is Latin1 encoded
§Safety
Caller must ensure that the string is encoded in Latin1.
If the string contains characters outside the Latin1 range, it may lead to encoding errors,
resulting in an incorrect or malformed JsString. This could cause undefined behavior
when the resulting string is used in further operations or when interfacing with other
parts of the system that expect valid Latin1 encoded string.