javascript - JS equivalent of file_get_contents in PHP?

one text

I am trying to rewrite some code from PHP to JavaScript. To start off, I am trying to read the content from a file, but for some reason I am getting unexpected results

In PHP I have:

$raw = file_get_contents(basename("input", ".swf"));
echo strlen($raw); // 13454%

And in JS:

import { readFile } from "fs/promises";

const raw = await readFile("./input.swf", "utf8");
console.log(raw.length); // 12710

How can I get the same output in JS as in PHP?

Source