i am getting some datas from .txt with fs.readFile()
function but top of the content is like "?Alex libman"
My whole code ;
fs.readFile(__dirname+"/txts/generate/titles0.txt", "utf-8", function (ex, titles) {
var titlesArr = titles.split("\r\n");
console.log(titlesArr);
});
Result;
["?Alex libman","Kroya Barzo","Deliah Krbo"]
Always , there is question mark at top of content
Note:my titles0.txt is line by line data
You need to convert your file to UTF-8 without BOM. You can do that by using this command in your terminal:
tail --bytes=+4 utf8_with_bom.txt > utf8_without_bom.txt
Or you may remove BOM with the help of text editors like Sublime Text (File -> Save with Encoding -> UTF-8
) or Notepad++ (Encoding -> Convert to UTF-8 without BOM
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With