SHARE
TWEET

Untitled

a guest Oct 19th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn main() {
  2.     let s = "Árvíztűrő pадио";
  3.     let bv: Vec<_> = s.bytes().collect();
  4.     let cv: Vec<_> = s.chars().collect();
  5.    
  6.     println!("String: {}", s);
  7.     println!("Bytevector (dec): {:?}", bv);
  8.     println!("Bytevector (hex): {:#02x?}", bv);
  9.     println!("Charvector: {:?}", cv);
  10.  
  11.     println!("---- visszaalakítás -----");
  12.  
  13.     if let Ok(s_from_bytevec) = String::from_utf8(bv) {
  14.         println!("String from bytevector: {}", s_from_bytevec);
  15.     } else {
  16.         println!("String fron bytevector - UTF8 ERROR");
  17.     }
  18.    
  19.     let s_from_charvec: String = cv.iter().collect();
  20.     println!("String from charvector: {}", s_from_charvec);
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top