writing a text file with lines coded in Unix

writing a text file with lines coded in Unix

Page 1 of 1

3 Replies - 8308 Views - Last Post: 16 January 2009 - 08:37 AM Rate Topic: -----

#1 ghinwa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-January 09

writing a text file with lines coded in Unix

Posted 16 January 2009 - 07:48 AM

the end of line in windows is "\r\n" where as in Unix it is \n
im using .net to write a text file and i need the lines to be coded in Unix - ( i need them to be readable in Unix)

how can i write a text file with end of line \n so that it can be readable in Unix?
Is This A Good Question/Topic? 0
  • +

Replies To: writing a text file with lines coded in Unix

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: writing a text file with lines coded in Unix

Posted 16 January 2009 - 07:56 AM

See String.Replace Method (String, String)

This post has been edited by n8wxs: 16 January 2009 - 07:59 AM

Was This Post Helpful? 0
  • +
  • -

#3 ghinwa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-January 09

Re: writing a text file with lines coded in Unix

Posted 16 January 2009 - 08:25 AM

View Postn8wxs, on 16 Jan, 2009 - 06:56 AM, said:


thanks i will give it a try
Was This Post Helpful? 0
  • +
  • -

#4 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5943
  • View blog
  • Posts: 12,871
  • Joined: 16-October 07

Re: writing a text file with lines coded in Unix

Posted 16 January 2009 - 08:37 AM

View Postghinwa, on 16 Jan, 2009 - 08:48 AM, said:

how can i write a text file with end of line \n so that it can be readable in Unix?


First, the pair is CR(13) and LF(10). When you say "\n" on a windows based system, you'll get CR+LF. When you say "\n" on *nix you get LF. The "\n" and "\r" aren't required to be mapped to a specific ASCII char.

If you're translating for Unix, you can simply remove all the CR. Or, if you're creating the file yourself, just send LF and use writes instead of write lines.

This post has been edited by baavgai: 16 January 2009 - 08:38 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1