mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 01:01:15 -06:00
Fixed ASCII folding for non-foldable non-ASCII characters
Problem: Add an object, name it using cyrilic, Slice, click Export: the proposed name is mangled. Affects all platforms, 2.2.0 was fine.
Cause: It is mangled during ASCII folding, which was broken with 28c0880 when it was generalized to be used from the fuzzy matcher.
fold_to_ascii(wchar_t c, char *out) relies on narrowing char = wchar_t assignment, the old one used std::back_insert_iterator<std::wstring>.
It is thus unable to leave a character alone even when it should (it should, right?).
Solution:
1. Typed the fold_to_ascii function so it works on wchar_t only, which should mimic the old behaviour.
2. Changed the respective call in fts_fuzzy_match.h. That function also works with wide char C-strings.
Cleanup:
1. Removed the unused fold_utf8_to_ascii(const char *src) overload to avoid code duplication.
2. Untemplated the fold_to_ascii(wchar_t c, std::back_insert_iterator<std::wstring>& out) function, it was never called with a different type.
3. The function is now static in ASCIIFolding.cpp, nobody else needs to know.
This commit is contained in:
parent
1f5ac7d2f7
commit
78a3d8b63e
3 changed files with 17 additions and 29 deletions
|
|
@ -7,23 +7,13 @@ namespace Slic3r {
|
|||
|
||||
// If possible, remove accents from accented latin characters.
|
||||
// This function is useful for generating file names to be processed by legacy firmwares.
|
||||
extern std::string fold_utf8_to_ascii(const char *src);
|
||||
extern std::string fold_utf8_to_ascii(const std::string &src);
|
||||
|
||||
// Convert the input UNICODE character to a string of maximum 4 output ASCII characters.
|
||||
// Return the end of the string written to the output.
|
||||
// The output buffer must be at least 4 characters long.
|
||||
extern char* fold_to_ascii(wchar_t c, char *out);
|
||||
extern wchar_t* fold_to_ascii(wchar_t c, wchar_t *out);
|
||||
|
||||
template<typename OUTPUT_ITERATOR>
|
||||
void fold_to_ascii(wchar_t c, OUTPUT_ITERATOR out)
|
||||
{
|
||||
char tmp[4];
|
||||
char *end = fold_to_ascii(c, tmp);
|
||||
for (char *it = tmp; it != end; ++ it)
|
||||
*out = *it;
|
||||
}
|
||||
|
||||
}; // namespace Slic3r
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_ASCIIFolding_hpp_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue