cbdeveloper
cbdeveloper

Reputation: 31345

Does Cloud Firestore save strings with newline \n characters (multiline)?

Apparently Cloud Firestore console does not display newline characters inside strings. Is there a way to inspect them?

enter image description here

This string saved is actually:

enter image description here

QUESTION

Can I be sure that the newlines are there, even though they're not visible on the Firestore Console?

Upvotes: 11

Views: 7507

Answers (3)

Akash Shah
Akash Shah

Reputation: 171

Replace the loaded string '\\n' with '\n' in the program and you can add '\n' in the database:

text.replaceAll('\\n', '\n');

Upvotes: 1

Omolayo Seun
Omolayo Seun

Reputation: 105

The method I have been using is to save the text in URL encoded format and decode it in your app or website. This method is good since URL encoding converts newlines, spaces and tabs to characters which are safe for transmitting over Internet.

Upvotes: 0

Frank van Puffelen
Frank van Puffelen

Reputation: 598740

Strings are stored unmodified, but various parts of the Firestore console show the newline character in different ways. Also see my previous answer on Firebase Firestore new line command and Doug's answer here: New Line Command (\n) Not Working With Firebase Firestore Database Strings.

Since the behavior is confusing to you, please file a bug report. But rest assured: your newline characters are stored and read correctly.

Upvotes: 3

Related Questions