1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/valkmjolnir-Nasal-Interpreter

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Это зеркальный репозиторий, синхронизируется ежедневно с исходного репозитория.
Клонировать/Скачать
util.h 1.5 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
ValKmjolnir Отправлено 10 месяцев назад f6d4d79
#pragma once
#include "nasal.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <cstring>
#include <sstream>
namespace nasal::util {
bool is_windows();
bool is_linux();
bool is_macos();
bool is_x86();
bool is_amd64();
bool is_x86_64();
bool is_arm();
bool is_aarch64();
bool is_ia64();
bool is_powerpc();
bool is_superh();
const char* get_platform();
const char* get_arch();
u32 utf8_hdchk(const char);
std::string char_to_hex(const char);
std::string rawstr(const std::string&, const usize maxlen = 0);
f64 hex_to_f64(const char*);
f64 oct_to_f64(const char*);
// we have the same reason not using atof here
// just as andy's interpreter does.
// it is not platform independent, and may have strange output.
// so we write a new function here to convert str to number manually.
// but this also makes 0.1+0.2==0.3,
// not another result that you may get in other languages.
f64 dec_to_f64(const char*);
f64 str_to_num(const char*);
class windows_code_page_manager {
private:
u32 code_page;
public:
windows_code_page_manager() {
#ifdef _WIN32
code_page = GetConsoleOutputCP();
#endif
}
void set_utf8_output() {
#ifdef _WIN32
// store previous code page
code_page = GetConsoleOutputCP();
// allow 65001 code page
SetConsoleOutputCP(CP_UTF8);
#endif
}
void restore_code_page() {
#ifdef _WIN32
// restore previous code page
SetConsoleOutputCP(code_page);
#endif
}
};
}

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/valkmjolnir-Nasal-Interpreter.git
git@gitlife.ru:oschina-mirror/valkmjolnir-Nasal-Interpreter.git
oschina-mirror
valkmjolnir-Nasal-Interpreter
valkmjolnir-Nasal-Interpreter
master