#ifdef __linux__ 

#ifndef LINSTUFF_H
#define LINSTUFF_H

#include <iostream>
#include <cstdlib>
#include <cstring>
#include "src/asserts.h"

class MyLocale {
	static bool m_initialized;
	static bool m_utf8;
	static bool set_utf8(const char *name) {
		const char *value = std::getenv(name);
		if (!value) return false;
		m_utf8 = std::strstr(value,"UTF-8") || std::strstr(value,"utf-8")
				 || std::strstr(value,"UTF8") || std::strstr(value,"utf8");
		return true;
	}
	static void set_utf8() {
		if (set_utf8("LC_ALL")) return; // LC_ALL overwrites al LC_* (setted or not)
		if (set_utf8("LC_CTYPE")) return; // LC_CTYPE seems to be the interesting one for my code
		if (set_utf8("LANG")) return; // LANG provides a default value for unsetted LC_*
	}
public:
	static void Init() { 
		EXPECT(m_initialized==false);
		set_utf8(); m_initialized = true; 
	}
	static bool IsUTF8() { 
		EXPECT(m_initialized==true);
		return m_initialized; 
	}
};

#endif

#endif
