
#ifndef PORYGONLANG_STRINGUTILS_HPP
#define PORYGONLANG_STRINGUTILS_HPP

#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
#include <sstream>

namespace Porygon::Utilities{
    class StringUtils{
    private:
        static std::wstring_convert<std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::little_endian>, char16_t> to_16;
    public:
        inline static std::u16string IntToString(long const &i) {
            return to_16.from_bytes(std::to_string(i));
        }
        inline static std::u16string FloatToString(double const &i) {
            return to_16.from_bytes(std::to_string(i));
        }

        inline static std::u16string ToUTF8(const std::string &s) {
            return to_16.from_bytes(s);
        }
        inline static std::string FromUTF8(const std::u16string &s) {
            return to_16.to_bytes(s);
        }

        inline static int64_t ParseInteger(const std::u16string &s){
            auto parsed = std::stol(FromUTF8(s));
            return parsed;
        }

        inline static double ParseFloat(const std::u16string &s){
            auto parsed = std::stod(FromUTF8(s));
            return parsed;
        }
    };
}

#endif //PORYGONLANG_STRINGUTILS_HPP
