# Module proper_unicode

- Description
- Data Types
- Function Index
- Function Details

Unicode generators for PropEr.

Copyright © 2014 Motiejus Jakstys

Authors: Motiejus Jakstys.

## Description

Unicode generators for PropEr

This module exposes utf8 binary and string generators.

Makes it easy to create custom-encoded unicode binaries and strings. For example, utf16 binary generator:

       utf16() ->
           ?LET(S, utf8(), unicode:characters_to_binary(S, utf8, utf16)).

Verify it has at least twice as many bytes as codepoints:

       ?FORALL(S, utf16(),
               size(S) >= 2*length(unicode:characters_to_list(S, utf16))).

## Data Types

### nonnegextint()

    nonnegextint() = non_neg_integer() | inf

## Function Index

utf8/0 | utf8-encoded unbounded size binary.
utf8/1 | utf8-encoded bounded upper size binary.
utf8/2 | Bounded upper size utf8 binary, `codepoint length =< MaxCodePointSize`.
utf8_string/0 | utf8-encoded unbounded size string.
utf8_string/1 | utf8-encoded bounded upper size string.
utf8_string/2 | Bounded upper size utf8 string, `codepoint length =< MaxCodePointSize`.

## Function Details

### utf8/0

    utf8() -> proper_types:type()

utf8-encoded unbounded size binary.

### utf8/1

    utf8(N :: nonnegextint()) -> proper_types:type()

utf8-encoded bounded upper size binary.

### utf8/2

    utf8(N :: nonnegextint(), MaxCodePointSize :: 1..4) ->
            proper_types:type()

Bounded upper size utf8 binary, `codepoint length =< MaxCodePointSize`.

Limiting codepoint size can be useful when applications do not accept full unicode range. For example, MySQL in utf8 encoding accepts only 3-byte unicode codepoints in VARCHAR fields.

If unbounded length is needed, use `inf` as first argument.

### utf8_string/0

    utf8_string() -> proper_types:type()

utf8-encoded unbounded size string.

### utf8_string/1

    utf8_string(N :: nonnegextint()) -> proper_types:type()

utf8-encoded bounded upper size string.

### utf8_string/2

    utf8_string(N :: nonnegextint(), MaxCodePointSize :: 1..4) ->
                   proper_types:type()

Bounded upper size utf8 string, `codepoint length =< MaxCodePointSize`.

Generated by EDoc