line-endings

How can I keep UNIX LF line endings?

百般思念 提交于 2021-02-08 07:25:41
问题 I have a large (9 GiB), ASCII encoded, pipe delimited file with UNIX-style line endings; 0x0A. I want to sample the first 100 records into a file for investigation. The following will produce 100 records (1 header record and 99 data records). However, it changes the line endings to DOS/Winodws style; CRLF, 0x0D0A. Get-Content -Path .\wellmed_hce_elig_20191223.txt | Select-Object -first 100 | Out-File -FilePath .\elig.txt -Encoding ascii I know about iconv, recode, and dos2unix. Those programs

How can I keep UNIX LF line endings?

淺唱寂寞╮ 提交于 2021-02-08 07:25:05
问题 I have a large (9 GiB), ASCII encoded, pipe delimited file with UNIX-style line endings; 0x0A. I want to sample the first 100 records into a file for investigation. The following will produce 100 records (1 header record and 99 data records). However, it changes the line endings to DOS/Winodws style; CRLF, 0x0D0A. Get-Content -Path .\wellmed_hce_elig_20191223.txt | Select-Object -first 100 | Out-File -FilePath .\elig.txt -Encoding ascii I know about iconv, recode, and dos2unix. Those programs

sourcetree line ending issue

感情迁移 提交于 2021-02-07 18:19:11
问题 I am getting a very strange whitespace issue. I am working with a local copy of a WordPress site with the .git repo in the wp-content/themes folder so all changes to any theme are tracked etc. When I set up the repo it considered every file (apart from those in gitignore) as new files and I committed those as the 'initial commit'. Firstly is that normal? To have to commit all the files when setting up a new repo? 2nd - and this is the strange behaviour. when I go to stage these files I get

Marshalling CDATA elements with CDATA_SECTION_ELEMENTS adds carriage return characters

断了今生、忘了曾经 提交于 2020-06-27 17:58:07
问题 I'm working on an application that exports and imports data from / to a DB. The format of the data extract is XML and I'm using JAXB for the serialization / (un)marshalling. I want some elements to be marshalled as CDATA elements and am using this solution which sets OutputKeys.CDATA_SECTION_ELEMENTS to the Transformer properties. So far this was working quite well, but now I came to a field in the DB that itself contains an XML string, which I also would like to place inside of a CDATA

Crazy PHP fopen / fwrite / file_put_contents / move_uploaded_file bug with binary mode writing on CentOS Linux Adding 0x0D to every 0x0A

天涯浪子 提交于 2020-06-13 05:03:32
问题 Seems the file keeps adding 0x0D to my saved binary files no matter what setting I put in the fopen mode flag. It's not only affecting fopen / fwrite .. but also file_put_contents . file_get_contents I thought was the problem to begin with.. but it turns out this one is actually working okay.. because when I dumped the file using bin2hex() it came out good. I was blaming at first the std::string in C++ for this bug.. but it turns out it doesn't even have anything to do with C++ but it's in

Crazy PHP fopen / fwrite / file_put_contents / move_uploaded_file bug with binary mode writing on CentOS Linux Adding 0x0D to every 0x0A

青春壹個敷衍的年華 提交于 2020-06-13 05:01:27
问题 Seems the file keeps adding 0x0D to my saved binary files no matter what setting I put in the fopen mode flag. It's not only affecting fopen / fwrite .. but also file_put_contents . file_get_contents I thought was the problem to begin with.. but it turns out this one is actually working okay.. because when I dumped the file using bin2hex() it came out good. I was blaming at first the std::string in C++ for this bug.. but it turns out it doesn't even have anything to do with C++ but it's in

How to make all line endings (EOLs) in all files in Visual Studio Code, UNIX like?

时间秒杀一切 提交于 2020-06-10 07:22:11
问题 I use Windows 10 home and I usually use Visual Studio Code (VSCODE) to edit Linux Bash scripts as well as PHP and JavaScript. I don't develop anything dedicated for Windows and I wouldn't mind that the default EOLs for all files I edit whatsoever would be Unix like (nix). How could I ensure that all EOLs, in all files whatsoever (from whatever file extension), are nix, in VSCODE? I ask this question after I've written a few Bash scripts in Windows with VSCODE, uploaded them to GitHub as part

On windows, how would I detect the line ending of a file?

天涯浪子 提交于 2020-05-26 11:17:20
问题 I've seen answers to the questions, but those answers are not from a windows perspective from what I can tell. Windows uses CR LF, Unix uses LF, Mac uses LF and classic mac uses something else. I don't have the brainpower to tell that somehow, if a file is using a different line ending than what I am typing, I get errors when trying to run the script/program which frankly, don't make much sense. After conversion, the script works just fine. Is there anyway to preemptively check what line

Vim: Mac vs. Linux ^M Problem

回眸只為那壹抹淺笑 提交于 2020-01-23 09:55:44
问题 I use Vim and GIT to develop my project on a Linux/Ubuntu machine. In the past, I used to use Windows, which means line ends were DOS format. Now after moving to Linux, I always see ^M confusing/annoying characters at the end of the line. Some people here: How to convert the ^M linebreak to 'normal' linebreak in a file opened in vim? suggested that I should make a find/replace or use tools like dos2unix. These are good suggestions, but with a version-controlled project it means I have to add

How to force consistent line endings in Git commits with cross-platform compatibility

时光怂恿深爱的人放手 提交于 2020-01-21 19:39:50
问题 I am having issues with merge conflicts due to line endings while working with someone who uses a different OS. I work on Windows and my colleague is on Mac. When he pushes his changes, sometimes files he hasn't worked on show up in the diff as being changed, because the line endings now show ^M on each file. This has lead to merge conflicts. I read in the Git docs the following: Git can handle this by auto-converting CRLF line endings into LF when you add a file to the index, and vice versa