Files
Upsilon/ion/src/simulator/linux/platform_language.cpp
Leviathan3DPrinting ac71576acc [Ion] Prevent crash if locale is null (#365)
* fix a compilation issue

* revert file

---------

Co-authored-by: Leviathan3DPrinting <leviathan3dprinting@gmail.com>
2024-05-12 11:35:12 +00:00

22 lines
416 B
C++

#include "../shared/platform.h"
#include <locale.h>
namespace Ion {
namespace Simulator {
namespace Platform {
const char * languageCode() {
static char buffer[3] = {0};
char * locale = setlocale(LC_ALL, "");
if (locale && locale[2] == '_') { // Check if locale is not null before accessing its elements
buffer[0] = locale[0];
buffer[1] = locale[1];
return buffer;
}
return nullptr;
}
}
}
}