Move from WideCStr to U16CStr

This commit is contained in:
xavo95 2025-03-09 20:12:19 +01:00
parent dde535bafb
commit 07330a27e1
Signed by: xavo95
GPG key ID: CBF8ADED6DEBB783
2 changed files with 9 additions and 8 deletions

View file

@ -1,7 +1,7 @@
use std::fmt::{Display, Formatter};
use std::sync::OnceLock;
use widestring::{WideCStr, WideCString};
use widestring::{U16CStr, U16CString};
use crate::{Add, Container};
use crate::t_array::TArray;
@ -25,7 +25,7 @@ impl FString {
impl Printf<str> for FString {
#[inline(always)]
fn printf<A: AsRef<str>>(handle: usize, fmt: A) {
let tmp = WideCString::from_str(fmt).unwrap();
let tmp = U16CString::from_str(fmt).unwrap();
unsafe {
std::mem::transmute::<usize, FStringPrintf>(*fstring_printf())(
handle,
@ -35,11 +35,12 @@ impl Printf<str> for FString {
}
}
impl<'a> Container<&'a WideCStr> for FString {
impl<'a> Container<&'a U16CStr> for FString {
#[inline(always)]
fn read_container(&self) -> &'a WideCStr {
fn read_container(&self) -> &'a U16CStr {
unsafe {
WideCStr::from_ptr(self.0.data_ptr as *const u16, self.0.len as usize - 1)
// TODO: Verify this in linux when symphonic is ready
U16CStr::from_ptr(self.0.data_ptr as *const u16, self.0.len as usize - 1)
}.unwrap()
}
}

View file

@ -1,7 +1,7 @@
use std::fmt::{Display, Formatter};
use std::sync::OnceLock;
use widestring::WideCStr;
use widestring::U16CStr;
use crate::{Add, Container};
use crate::f_string::FString;
@ -109,8 +109,8 @@ impl TArray {
}
}
impl<'a> Container<Vec<&'a WideCStr>> for TArray {
fn read_container(&self) -> Vec<&'a WideCStr> {
impl<'a> Container<Vec<&'a U16CStr>> for TArray {
fn read_container(&self) -> Vec<&'a U16CStr> {
let mut result = Vec::with_capacity(self.len as usize);
for i in 0..self.len {
result.push(