You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
File: Re-add support to skip CR (\r) in File::get_as_text
This was removed in #63481, and we confirmed that it's better like this, but we add back the possibility to strip CR as an option, to optionally restore the previous behavior. For performance this is done directly in `String::parse_utf8`. Also fixes Android `FileAccess::get_line()` as this one _should_ strip CR. Supersedes #63717.
This commit is contained in:
@@ -377,7 +377,7 @@ uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
|
||||
return i;
|
||||
}
|
||||
|
||||
String FileAccess::get_as_utf8_string() const {
|
||||
String FileAccess::get_as_utf8_string(bool p_skip_cr) const {
|
||||
Vector<uint8_t> sourcef;
|
||||
uint64_t len = get_length();
|
||||
sourcef.resize(len + 1);
|
||||
@@ -388,7 +388,7 @@ String FileAccess::get_as_utf8_string() const {
|
||||
w[len] = 0;
|
||||
|
||||
String s;
|
||||
s.parse_utf8((const char *)w);
|
||||
s.parse_utf8((const char *)w, -1, p_skip_cr);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user