diff --git a/crates/libs/registry/src/value.rs b/crates/libs/registry/src/value.rs index 5e41c028a6..594162c227 100644 --- a/crates/libs/registry/src/value.rs +++ b/crates/libs/registry/src/value.rs @@ -17,6 +17,11 @@ impl Value { pub fn set_ty(&mut self, ty: Type) { self.ty = ty; } + + /// Gets the value as a slice of u16 for raw wide characters. + pub fn as_wide(&self) -> &[u16] { + self.data.as_wide() + } } impl core::ops::Deref for Value { diff --git a/crates/tests/registry/tests/value.rs b/crates/tests/registry/tests/value.rs index c2589a36be..deb0929621 100644 --- a/crates/tests/registry/tests/value.rs +++ b/crates/tests/registry/tests/value.rs @@ -77,5 +77,10 @@ fn value() -> Result<()> { (Type::String, 16) ); + let abc = Value::try_from("abc")?; + assert_eq!(abc.as_wide(), &[97, 98, 99, 0]); + let abc = Value::try_from(h!("abcd"))?; + assert_eq!(abc.as_wide(), &[97, 98, 99, 100, 0]); + Ok(()) }