mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 08:41:11 -06:00

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.
19 lines
643 B
C++
19 lines
643 B
C++
#ifndef slic3r_ASCIIFolding_hpp_
|
|
#define slic3r_ASCIIFolding_hpp_
|
|
|
|
#include <string>
|
|
|
|
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 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 wchar_t* fold_to_ascii(wchar_t c, wchar_t *out);
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif /* slic3r_ASCIIFolding_hpp_ */
|