joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.8k stars 770 forks source link

readFile doesn't escape characters #784

Closed humble-programmer closed 2 years ago

humble-programmer commented 2 years ago

React Native version: 0.66.0 rn-fetch-blob version: 0.12.0

I'm using rn-fetch-blob to read a utf-8 file. This file contains \n characters within its content. However, these \n characters aren't newline characters. They are two separate characters \ and n. In other words, when opening this file on a text editor, \n characters will be visible instead of a newline. However, when reading the file with readFile, these characters are read as \n like a single newline character, instead of escaping the backslash and reading as \n.

import RNFetchBlob from 'rn-fetch-blob';

RNFetchBlob.fs.readFile('path-to-file');

UPDATE: I have closed this issue as the error was due to a bug in my own code.