mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-09 10:16:50 +00:00
fix: STEP part names with accented characters import as numbers (clears 6 warnings) (#15406)
This commit is contained in:
@@ -55,9 +55,9 @@ bool load_obj(const char *path, TriangleMesh *meshptr, ObjInfo& obj_info, std::s
|
||||
boost::filesystem::path temp_mtl_path(mtl_file);
|
||||
mtl_path = temp_mtl_path;
|
||||
}
|
||||
auto _mtl_path = mtl_name_is_path ? mtl_abs_path.string().c_str() : mtl_path.string().c_str();
|
||||
const std::string _mtl_path = (mtl_name_is_path ? mtl_abs_path : mtl_path).string();
|
||||
if (boost::filesystem::exists(mtl_name_is_path ? mtl_abs_path : mtl_path)) {
|
||||
if (!ObjParser::mtlparse(_mtl_path, mtl_data)) {
|
||||
if (!ObjParser::mtlparse(_mtl_path.c_str(), mtl_data)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "load_obj:load_mtl: failed to parse " << _mtl_path;
|
||||
message = _L("load mtl in obj: failed to parse");
|
||||
return false;
|
||||
|
||||
@@ -111,14 +111,19 @@ bool StepPreProcessor::isUtf8File(const char* path)
|
||||
bool StepPreProcessor::isUtf8(const std::string str)
|
||||
{
|
||||
size_t num = 0;
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
while (i < str.length()) {
|
||||
if ((str[i] & 0x80) == 0x00) {
|
||||
const unsigned char lead = static_cast<unsigned char>(str[i]);
|
||||
if ((lead & 0x80) == 0x00) {
|
||||
i++;
|
||||
} else if ((num = preNum(str[i])) > 2) {
|
||||
// preNum() counts the leading 1 bits, and a multi-byte sequence is 2 to 4
|
||||
// bytes long, so anything outside that range is not a lead byte.
|
||||
} else if ((num = preNum(lead)) >= 2 && num <= 4) {
|
||||
if (i + num > str.length())
|
||||
return false;
|
||||
i++;
|
||||
for (int j = 0; j < num - 1; j++) {
|
||||
if ((str[i] & 0xc0) != 0x80)
|
||||
for (size_t j = 0; j < num - 1; j++) {
|
||||
if ((static_cast<unsigned char>(str[i]) & 0xc0) != 0x80)
|
||||
return false;
|
||||
i++;
|
||||
}
|
||||
@@ -132,15 +137,20 @@ bool StepPreProcessor::isUtf8(const std::string str)
|
||||
bool StepPreProcessor::isGBK(const std::string str) {
|
||||
size_t i = 0;
|
||||
while (i < str.length()) {
|
||||
if (str[i] <= 0x7f) {
|
||||
// char is signed here, so every byte compares <= 0x7f unless widened first.
|
||||
const unsigned char lead = static_cast<unsigned char>(str[i]);
|
||||
if (lead <= 0x7f) {
|
||||
i++;
|
||||
continue;
|
||||
} else {
|
||||
if (str[i] >= 0x81 &&
|
||||
str[i] <= 0xfe &&
|
||||
str[i + 1] >= 0x40 &&
|
||||
str[i + 1] <= 0xfe &&
|
||||
str[i + 1] != 0xf7) {
|
||||
if (i + 1 >= str.length())
|
||||
return false;
|
||||
const unsigned char trail = static_cast<unsigned char>(str[i + 1]);
|
||||
if (lead >= 0x81 &&
|
||||
lead <= 0xfe &&
|
||||
trail >= 0x40 &&
|
||||
trail <= 0xfe &&
|
||||
trail != 0xf7) {
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user