Skip to content

Commit 4ee2758

Browse files
committed
Just check for FFFD
1 parent 2f597d5 commit 4ee2758

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/scanner.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1796,15 +1796,15 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
17961796
const ch = codePointAt(text, pos);
17971797
if (pos === 0) {
17981798
// If a file isn't valid text at all, it will usually be apparent
1799-
// in the first few characters because we'll see a NUL or UTF-8 decode will fail and produce U+FFFD.
1799+
// in the first few characters because UTF-8 decode will fail and produce U+FFFD.
18001800
// If that happens, just issue one error and refuse to try to scan further;
18011801
// this is likely a binary file that cannot be parsed.
18021802
let i = 0;
18031803
const stop = Math.min(text.length, 256);
18041804
while (i < stop) {
18051805
const ch = codePointAt(text, i);
18061806
// Jump to the end of the file and fail.
1807-
if (ch === CharacterCodes.nullCharacter || ch === CharacterCodes.replacementCharacter) {
1807+
if (ch === CharacterCodes.replacementCharacter) {
18081808
error(Diagnostics.File_appears_to_be_binary);
18091809
pos = end;
18101810
return token = SyntaxKind.NonTextFileMarkerTrivia;

0 commit comments

Comments
 (0)