unicode generation

group turbo_random_unicode

Turbo Random Module.

class Utf8Generator
#include <unicode.h>

Generates random UTF-8 sequences.

The generator is based on the following probabilities:

  • 1 byte: 0x00 - 0x7f (127)

  • 2 bytes: 0xc2 - 0xdf (192 - 223)

  • 3 bytes: 0xe0 - 0xef (224 - 239)

  • 4 bytes: 0xf0 - 0xf4 (240 - 244) The probabilities are configurable. Example:

    Utf8Generator gen(50, 30, 15, 5);
    std::vector<uint8_t> bytes = gen.generate(100);
    
    The example above will generate 100 random bytes with the following probabilities:

  • 1 byte: 50%

  • 2 bytes: 30%

  • 3 bytes: 15%

  • 4 bytes: 5%

Note

The generator is not thread-safe.

class Utf16Generator
#include <unicode.h>

Generates random UTF-16 sequences.

The generator is based on the following probabilities:

  • 1 word: 0x0000 - 0xd7ff (0 - 55295)

  • 2 words: 0xe000 - 0xffff (57344 - 65535)

  • 2 words: 0x10000 - 0x10ffff (65536 - 1114111) The probabilities are configurable. Example:

    Utf16Generator gen(50, 50);
    std::vector<uint16_t> words = gen.generate(100);
    
    The example above will generate 100 random words with the following probabilities:

  • 1 word: 50%

  • 2 words: 50%

Note

The generator is not thread-safe.

class Utf32Generator
#include <unicode.h>

Generates random UTF-32 sequences.

by the following formula: Example:

Utf32Generator gen;
std::vector<uint32_t> words = gen.generate(100);