public static void randomFixedLengthUnicodeString(Random random,char[] chars,int offset,int length){
  int i=offset;
  final int end=offset + length;
  while (i < end) {
    final int t=random.nextInt(5);
    if (0 == t && i < length - 1) {
      chars[i++]=(char)nextInt(random,0xd800,0xdbff);
      chars[i++]=(char)nextInt(random,0xdc00,0xdfff);
    }
 else     if (t <= 1) {
      chars[i++]=(char)random.nextInt(0x80);
    }
 else     if (2 == t) {
      chars[i++]=(char)nextInt(random,0x80,0x7ff);
    }
 else     if (3 == t) {
      chars[i++]=(char)nextInt(random,0x800,0xd7ff);
    }
 else     if (4 == t) {
      chars[i++]=(char)nextInt(random,0xe000,0xffff);
    }
  }
}

public static void randomFixedLengthUnicodeString ( Random random , char [ ] chars , int offset , int length ) { int i = offset ; final int end = offset + length ; while ( i < end ) { final int t = random . nextInt ( 5 ) ; if ( 0 == t && i < length - 1 ) { chars [ i ++ ] = ( char ) nextInt ( random , 0xd800 , 0xdbff ) ; chars [ i ++ ] = ( char ) nextInt ( random , 0xdc00 , 0xdfff ) ; } else if ( t <= 1 ) { chars [ i ++ ] = ( char ) random . nextInt ( 0x80 ) ; } else if ( 2 == t ) { chars [ i ++ ] = ( char ) nextInt ( random , 0x80 , 0x7ff ) ; } else if ( 3 == t ) { chars [ i ++ ] = ( char ) nextInt ( random , 0x800 , 0xd7ff ) ; } else if ( 4 == t ) { chars [ i ++ ] = ( char ) nextInt ( random , 0xe000 , 0xffff ) ; } } }
fills provided char [ ] with valid random unicode code unit sequence .
