Rebol 编程/enline
外观
< Rebol 编程
ENLINE series /with end-of-line
将标准字符串终止符转换为当前操作系统格式,例如 LF 到 CRLF。(修改)
ENLINE 是一个函数值。
- series -- (类型:any-string 块)
- /with -- 指定备用行终止符。
- end-of-line -- (类型:char 字符串)
enline: func [ {Converts standard string terminators to current OS format, e.g. LF to CRLF. (Modifies)} series [any-string! block!] /with "Specifies alternate line termination." end-of-line [char! string!] /local platform-line len len-eol output a ][ platform-line: "^M^/" switch type?/word end-of-line [ none! [end-of-line: platform-line] char! [end-of-line: to-string end-of-line] ] either block? series [ len: 0 len-eol: length? end-of-line foreach s series [len: len + len-eol + length? s] output: make string! len foreach s series [insert insert tail output s end-of-line] also output set [series output] none ] [ unless end-of-line = "^/" [ parse/all/case either binary? series [as-string series] [series] [ any [to lf a: lf (a: change/part a end-of-line 1) :a] to end ] ] also series set [series a] none ] ]