#ifndef ENCODING_H
#define ENCODING_H

#include <stdint.h>
#include <stdlib.h>

class Encoding
{
public:
    enum Type
    {
        UTF_8,
        CP_1252,
    };

    enum : uint32_t
    {
        MAX_CODE_POINT_SIZE = 8u,
    };

    static Type detect_encoding(const uint8_t * buffer, size_t length);
    static uint8_t num_bytes_in_code_point(Type type, const uint8_t * encoded);
    static const uint8_t * beginning_of_code_point(Type type, const uint8_t * encoded);
    static uint32_t decode(Type type, const uint8_t * encoded, uint8_t * encoded_size = nullptr);
    static uint8_t num_bytes_to_encode_code_point(uint32_t code_point, Type type);
    static uint8_t encode(uint32_t code_point, Type type, uint8_t * buffer);
};

#endif
