mirror of
https://github.com/godotengine/godot.git
synced 2025-10-25 18:54:43 +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.
(cherry picked from commit 1418f97c70)
This commit is contained in:
parent
f9db8fa70a
commit
751b16a285
8 changed files with 26 additions and 13 deletions
|
|
@ -29,8 +29,10 @@
|
|||
/*************************************************************************/
|
||||
|
||||
#include "file_access_filesystem_jandroid.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "thread_jandroid.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
jobject FileAccessFilesystemJAndroid::file_access_handler = nullptr;
|
||||
|
|
@ -197,7 +199,7 @@ String FileAccessFilesystemJAndroid::get_line() const {
|
|||
if (elem == '\n' || elem == '\0') {
|
||||
// Found the end of the line
|
||||
const_cast<FileAccessFilesystemJAndroid *>(this)->seek(start_position + line_buffer_position + 1);
|
||||
if (result.parse_utf8((const char *)line_buffer.ptr(), line_buffer_position)) {
|
||||
if (result.parse_utf8((const char *)line_buffer.ptr(), line_buffer_position, true)) {
|
||||
return String();
|
||||
}
|
||||
return result;
|
||||
|
|
@ -205,7 +207,7 @@ String FileAccessFilesystemJAndroid::get_line() const {
|
|||
}
|
||||
}
|
||||
|
||||
if (result.parse_utf8((const char *)line_buffer.ptr(), line_buffer_position)) {
|
||||
if (result.parse_utf8((const char *)line_buffer.ptr(), line_buffer_position, true)) {
|
||||
return String();
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue