line-endings

Python, read CRLF text file as is, with CRLF

你说的曾经没有我的故事 提交于 2019-12-04 00:29:01
问题 with open(fn, 'rt') as f: lines = f.readlines() This reads CR LF text file (WinXP, Py 2.6) with LF line ends. So lines contain '\n' ends. How to get lines as is: for CRLF file get lines with '\n\r' ends for LF file get lines with '\n' ends 回答1: Instead of the built-in open() function, use io.open(). This gives you more control over how newlines are handled with the newline argument: import io with io.open(fn, 'rt', newline='') as f: lines = f.readlines() Setting newline to the empty string,

How can I change the line endings used by fputcsv?

本小妞迷上赌 提交于 2019-12-03 19:32:45
问题 I create a CSV file for download by our client using $output = fopen('php://output', 'w'); and using fputcsv() to write data to a CSV file which is downloaded by the client. I am running PHP on Linux and consequently the line endings are not interpreted by many Windows applications. I could write the CSV file to a directory on the server, read it back in and perform a str_replace() from \n to \r\n , but this seems a rather clunky way of solving the problem. Is there a way to perform the

How to configure Compass to generate files with Unix line endings on Windows?

我与影子孤独终老i 提交于 2019-12-03 16:36:28
问题 I just installed Compass 0.11.5 on Windows 7 with Ruby 1.9.2. I have my development environment set up to use Unix line endings for all files. I created an initial sass-test project and noticed that all the files it created had Windows line endings. I moved an existing .css file from another project (with unix line endings) into the sass folder and changed the extension to .scss. I ran the 'compass compile' command to generate the .css file for this new file and the .css file it created had

Enforce core.autocrlf=input through .gitattributes

一个人想着一个人 提交于 2019-12-03 14:30:41
Is there a way to enforce core.autocrlf=input from within the .gitattributes in order to propagate the policy throughout my colleagues? In detail what I want is to convert to lf on add and leave as is on checkout . The problem is that neither text nor eol do what I want in .gitattributes since eol has 3 acceptable values: lf crlf native Ideally I would like my .gitattributes file to look like this: * text eol=asis In detail what I want is to convert to lf on commit and leave as is on checkout. Git doesn't convert on commit, but rather on git add . (More precisely, it does conversions on

git line endings : renormalize does not seem to checkout the right line endings

…衆ロ難τιáo~ 提交于 2019-12-03 14:05:45
I decided to set my line endings the Right Way via a .gitattributes file as detailed for instance here - so I set the core.autocrlf to false and created and committed a .gitattributes file : *.java text eol=native *.jsp text eol=native *.css text eol=native *.html text eol=native *.js text eol=native *.xml text eol=native *.sql text eol=native *.MF text eol=native # git files *.gitignore text eol=native *.gitattributes text eol=native #eclipse files *.classpath text eol=native *.project text eol=native *.prefs text eol=native *.properties text eol=native I then issued git rm --cached -r . and

How to fix inconsistent line endings for whole VS solution?

不羁的心 提交于 2019-12-03 04:43:19
问题 Visual Studio will detect inconsistent line endings when opening a file and there is an option to fix it for that specific file. However, if I want to fix line endings for all files in a solution, how do I do that? 回答1: Just for a more complete answer, this worked best for me: Replace (?<!\r)\n with \r\n in entire solution with "regEx" option. This will set the correct line ending in all files which didn't have the correct line ending so far. It uses the negative lookahead to check for the

Configure Visual Studio to use UNIX line endings

淺唱寂寞╮ 提交于 2019-12-03 04:41:11
问题 We would like to use Visual Studio 2005 to work on a local copy of an SVN repository. This local copy has been checked out by Mac OS X (and updates and commits will only be made under Mac OS X, so no problem there), and as a consequence the line endings are UNIX-style. We fear that Visual Studio will introduce Windows-style line endings. Is it possible to force Visual Studio to use UNIX line endings? 回答1: As OP states "File > Advanced Save Options", select Unix Line Endings. 回答2: Here are

How to avoid mixed eol-styles in a svn repository

旧城冷巷雨未停 提交于 2019-12-03 03:31:57
Is there a best practice for preventing mixed eol-styles in a subversion repository. I know that svn:eol-style=native can be set as an auto-prop, but I would have to ensure that it was set for all committers. I'm also reluctant to do a retrospective, repository-wide change of svn:eol-style if there is a less invasive solution. You should use pre-commit hooks on server-side. Here is a hook you need: http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/check-mime-type.pl This hook will enforce users to set correct eol-style. See svn documentation on how to use them. Also, you

How can I fix the SVN import line endings error?

混江龙づ霸主 提交于 2019-12-03 03:05:00
I have to import an huge SVN repository that I have to transfer from one server to another. So I exported it from the old server: svnadmin dump . > archive.svn and imported it on the new one: svnadmin load . < archive.svn In the middle of the import process I got this error: Cannot accept non-LF line endings in 'svn:ignore' property How can I fix this? I have full control of both servers. Mand Beckett Have you changed the server version? This is a known issue in 1.6, and causes problems when going from 1.4 or 1.5. Subversion 1.6 no longer accepts carriage returns (^M) in property files. You'll

How can I write a ESLint rule for “linebreak-style”, changing depending on Windows or Unix?

帅比萌擦擦* 提交于 2019-12-03 02:18:12
问题 As we all know, the linebreaks (new line) used in Windows are usually carriage returns (CR) followed by a line feed (LF) i.e. (CRLF) whereas, Linux and Unix use a simple line feed (LF) Now, in my case, my build server uses supports Linux and Unix format so, below rule is working perfectly on build server: linebreak-style: ["error", "unix"] But I am doing development on Windows and I need to update rule on each git pull/git push as below, linebreak-style: ["error", "windows"] So, is there any