Working With Text File Formats Print

  • 0

Line endings and encodings.

WHAT THE LINE ENDING PROBLEM IS

Windows uses two characters to end a line; Unix uses one.

WHAT THAT CAUSES

Scripts failing with obscure errors Configuration files not parsing Stray characters at line ends

WHAT THE CLASSIC SYMPTOM IS

A script reporting a bad interpreter, naming something that clearly exists.

WHY

The invisible carriage return became part of the interpreter's name.

HOW TO SEE THEM

The file command reports them, or view the file showing non-printing characters.

HOW TO CONVERT

A dedicated conversion tool, or a substitution with sed.

WHAT CAUSES IT

Editing a file on Windows and uploading it Copying through a program that rewrites line endings

WHAT PREVENTS IT

Editors configured to preserve Unix endings Transferring in binary mode

WHAT THE ENCODING PROBLEM IS

Text stored in one character set and read as another.

WHAT IT PRODUCES

Accented characters and symbols appearing as nonsense.

WHY IT MATTERS FOR DATABASES

Importing a dump with the wrong character set corrupts text permanently.

WHAT TO SPECIFY

The character set explicitly, on export and import.

WHAT TO USE THROUGHOUT

A single modern encoding.

WHAT TO CHECK AFTER ANY MIGRATION

Records containing accented or non-Latin characters.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot