Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flipping line endings in C++ (or R)

Tags:

c++

r

I have a C++ that I'm running though R (via Rcpp). Recently, I found that the C++ program I'm wrapping with Rcpp fails when using Windows-style line endings.

I'm wondering if anyone knows of a cross-platform way for me to change Windows-style line endings to Unix-style line endings in either C++ or R or ash shell (which comes installed with R).

Thanks!

like image 644
mudspattered Avatar asked Nov 15 '22 09:11

mudspattered


1 Answers

Use R function readLines, which is immune to various LEs, and then pass string vector to C++. Or, if you don't like to change the C++ part, use paste to change the LEs to whatever you want.

like image 123
mbq Avatar answered Dec 17 '22 10:12

mbq