You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fury.apache.org by "urlyy (via GitHub)" <gi...@apache.org> on 2024/07/06 03:25:47 UTC

Re: [I] [Rust] Support convert utf16 encoded string to utf8 string [fury]

urlyy commented on issue #1547:
URL: https://github.com/apache/fury/issues/1547#issuecomment-2211612233

   Hi, I've created a basic demo. Since Rust's string encoding is UTF-8, we can directly use the String's API to convert UTF-16 encoded data into a string. However, this method doesn't utilize SIMD. So, I'm wondering what else needs to be done on top of this. 
   ```rust
   fn main() {
       let s = "Hello";
       // initial utf-16 encoded data
       let utf16_encoded: Vec<u16> = s.encode_utf16().collect();
       // convert utf-16 to utf-8
       match String::from_utf16(&utf16_encoded) {
           Ok(string) => {
               // let utf8_data = string.into_bytes();
               println!("{}", string);
           }
           Err(e) => {
               println!("Error converting UTF-16 to UTF-8: {:?}", e);
           }
       }
   }
   ```
   I'm not familiar with high-performance computing and I've only found the [std::simd](https://doc.rust-lang.org/beta/std/simd/index.html) library, however, it is a **nightly-only experimental** API.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fury.apache.org
For additional commands, e-mail: commits-help@fury.apache.org