We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 271ff3f commit 8b99e2aCopy full SHA for 8b99e2a
llama.cpp
@@ -17940,7 +17940,16 @@ static std::string llama_decode_text(const std::string & text) {
17940
17941
const auto cpts = unicode_cpts_from_utf8(text);
17942
for (const auto cpt : cpts) {
17943
- decoded_text += unicode_utf8_to_byte(unicode_cpt_to_utf8(cpt));
+ const auto utf8 = unicode_cpt_to_utf8(cpt);
17944
+ try {
17945
+ decoded_text += unicode_utf8_to_byte(utf8);
17946
+ } catch (const std::out_of_range & e) {
17947
+ decoded_text += "[UNK_BYTE_0x";
17948
+ for (const auto c : utf8) {
17949
+ decoded_text += format("%02x", (uint8_t) c);
17950
+ }
17951
+ decoded_text += text + "]";
17952
17953
}
17954
17955
return decoded_text;
0 commit comments