rand_utf8

Function rand_utf8 

Source
pub fn rand_utf8<R: Rng>(rng: &mut R, len: usize) -> Box<str>
Expand description

Generate a valid random unicode string, targeting well distributed utf8 bytes. rand::distributions::DistString produces random u32 code points, but the majority of these code points produce 4 utf8 bytes each of which are > 128, resulting in poor distribution. This function mixes in random valid utf8 bytes < 128 to fix this issue. Bytes may not be very well distributed if len < 8.