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:
parent
14828c331c
commit
1418f97c70
15 changed files with 74 additions and 13 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public:
|
|||
virtual String get_line() const;
|
||||
virtual String get_token() const;
|
||||
virtual Vector<String> get_csv_line(const String &p_delim = ",") const;
|
||||
virtual String get_as_utf8_string() const;
|
||||
virtual String get_as_utf8_string(bool p_skip_cr = false) const;
|
||||
|
||||
/**
|
||||
* Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue