Add core.strip_escapes() - #16485
Conversation
|
What's the use case here? If it's "I want to remove all color and translation tokens" then the user should do server-side translation into English and strip colours. Just stripping the translation escape codes is quite questionable and unlikely to be what the user wants. It doesn't handle parameters in text |
|
@rubenwardy I'd use it to simplify this function, where I can't be sure whether the translated error message is sent to a player (translated) or in console (not translated) Alternatively, I could call |
Then we add font escapes next and the mod code is insufficient again. Small inconvenience sure, but being guaranteed to return plain text is the entire point.
It does, since that format was designed with that in mind :) Lines 628 to 638 in 6949720 |
Related nit: I wonder whether there might be a more "intuitive" name than Escapes is a bit of a technical term, and one we're not even using that consistently (for example the translation-related methods do not use the term in their names). What we want to express is that this turns our "rich" strings into "poor", "plain", "raw" (?) strings. Something like |
someone could as well mistake that for dealing with hypertext... |
LuaJIT on my machine: (strip_escapes2 is the C++ implementation) |
I'd say so, yes. |
To do
This PR is Ready for Review.