zoukankan      html  css  js  c++  java
  • Text and Binary modes

    http://perlmaven.com/what-is-a-text-file

    https://cygwin.com/cygwin-ug-net/using-textbinary.html

    Text and Binary modes

    The Issue

    On a UNIX system, when an application reads from a file it gets exactly what's in the file on disk and the converse is true for writing. The situation is different in the DOS/Windows world where a file can be opened in one of two modes, binary or text. In the binary mode the system behaves exactly as in UNIX. However on writing in text mode, a NL (\n, ^J) is transformed into the sequence CR (\r, ^M) NL.

    This can wreak havoc with the seek/fseek calls since the number of bytes actually in the file may differ from that seen by the application.

    The mode can be specified explicitly as explained in the Programming section below. In an ideal DOS/Windows world, all programs using lines as records (such as bashmakesed ...) would open files (and change the mode of their standard input and output) as text. All other programs (such as catcmptr ...) would use binary mode. In practice with Cygwin, programs that deal explicitly with object files specify binary mode (this is the case of od, which is helpful to diagnose CR problems). Most other programs (such as sedcmptr) use the default mode.

  • 相关阅读:
    typora 页内跳转
    shell脚本搭建redis集群
    Html
    python json模块
    jenkins 问题合集
    day05 每日一行
    day04 每次一行
    day03 每日一行
    day02
    day02 每日一行
  • 原文地址:https://www.cnblogs.com/hangj/p/3858941.html
Copyright © 2011-2022 走看看