22 lines
849 B
JavaScript
22 lines
849 B
JavaScript
const fs = require('fs');
|
|
const filePath = 'c:\\Users\\matthias.hoesch\\.gemini\\antigravity\\scratch\\vda-to-edifact-converter\\samples\\test_efz.edi';
|
|
const buffer = fs.readFileSync(filePath);
|
|
|
|
console.log('File size:', buffer.length);
|
|
|
|
const searchStr = 'Precision';
|
|
const searchBuf = Buffer.from(searchStr, 'utf8');
|
|
|
|
let index = buffer.indexOf(searchBuf);
|
|
if (index !== -1) {
|
|
console.log('Found "' + searchStr + '" at byte offset:', index);
|
|
const start = Math.max(0, index - 30);
|
|
const end = Math.min(buffer.length, index + 40);
|
|
const context = buffer.slice(start, end);
|
|
console.log('Context (hex):', context.toString('hex'));
|
|
console.log('Context (utf8):', context.toString('utf8'));
|
|
console.log('Context (latin1):', context.toString('latin1'));
|
|
} else {
|
|
console.log('"' + searchStr + '" not found in file.');
|
|
}
|