NROFF
text/troff
Magic Bytes
Offset: 0
2E 5C 22
NROFF is a text-formatting system developed by Joe Ossanna for the Unix operating system as a descendant of the earlier runoff program. It is primarily used to format manual pages and documentation for terminal display or line printers, typically processed by the GNU troff suite. Although largely a legacy format, it remains the standard for Unix man pages and is considered safe because it lacks executable scripts or complex embedded media.
Validation Code
How to validate .nroff files in Python
Python
def is_nroff(file_path: str) -> bool:
"""Check if file is a valid NROFF by magic bytes."""
signature = bytes([0x2E, 0x5C, 0x22])
with open(file_path, "rb") as f:
return f.read(3) == signature
How to validate .nroff files in Node.js
Node.js
function isNROFF(buffer: Buffer): boolean {
const signature = Buffer.from([0x2E, 0x5C, 0x22]);
return buffer.subarray(0, 3).equals(signature);
}
Go
func IsNROFF(data []byte) bool {
signature := []byte{0x2E, 0x5C, 0x22}
if len(data) < 3 {
return false
}
return bytes.Equal(data[:3], signature)
}
API Endpoint
GET
/api/v1/nroff
curl https://filesignature.org/api/v1/nroff