REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: deline

deline  string  /lines

Converts string terminators to standard format, e.g. CRLF to LF. (Modifies)

Arguments:

string [any-string!]

Refinements:

/lines - Return block of lines (works for LF, CR, CR-LF endings) (does not modify)

See also:

enline   read  

Description

Useful for converting OS dependent string terminators to LF.

CRLF string termination:

deline "a^M^/b" ; Windows, DOS, CP/M, OS/2, Symbian
"a^/b"

CR string termination:

deline "a^Mb" ; MacOS 1-9
"a^/b"

LF string termination:

deline "a^/b" ; MacOSX, AmigaOS, FreeBSD, GNU/Linux, BeOS, RiscOS
"a^/b"

When using the /LINES refinement, the string will be split in blocks of strings per line:

deline/lines "a^M^/b"
[
    "a"
    "b"
]

Note that when reading from disk, READ/STRING provides the same functionality. The file %/c/text.txt was first saved with WIndows XP Notepad, which gives CRLF. When read, it gives:

read/string %/c/text.txt
"Windows text^/file"


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin