| 133 | } | null | undefined; |
| 134 | |
| 135 | function normalizeText(input: string): string { |
| 136 | let normalized = ""; |
| 137 | for (const ch of input) { |
| 138 | const codePoint = ch.charCodeAt(0); |
| 139 | if (codePoint === 0x3000) { |
| 140 | normalized += " "; |
| 141 | continue; |
| 142 | } |
| 143 | if (codePoint >= 0xff01 && codePoint <= 0xff5e) { |
| 144 | normalized += String.fromCharCode(codePoint - 0xfee0); |
| 145 | continue; |
| 146 | } |
| 147 | normalized += ch; |
| 148 | } |
| 149 | |
| 150 | return normalized |
| 151 | .replace(/[\u200B-\u200D\uFEFF]/g, "") |
| 152 | .toLowerCase() |
| 153 | .replace(/\s+/g, " ") |
| 154 | .trim(); |
| 155 | } |
| 156 | |
| 157 | function isLikelyTextFile(filePath: string): boolean { |
| 158 | const ext = path.extname(filePath).toLowerCase(); |