7.1 transcoder
如上所述, transcoder 封装了3个值:一个 codec ,一个 eol-style,以及 error-handling-mode。本节介绍创建或操作 transcoder 的过程以及 transcoder 封装的值。
procedure: (make-transcoder codec)
procedure: (make-transcoder codec eol-style)
procedure: (make-transcoder codec eol-style error-handling-mode)
返回:一个 transcoder
库路径:(rnrs io ports), (rnrs)
codec
需要由下面的过程调用生成,比如 (utf-8-codec)
返回一个 UTF-8 codec。
eol-style
必须是合法的 eol-style 符号(lf, cr, nel, ls, crlf, crnel
或者none
),它默认为当前平台的本地风格(windows 下是 crlf, 而 Linux 下是 lf)。
error-handling-mode
必须是合法的错误处理模式(ignore, raise, replace
), 它的默认值为 replace
。
procedure: (transcoder-codec transcoder)
returns: the codec encapsulated in transcoder
procedure: (transcoder-eol-style transcoder)
returns: the eol-style symbol encapsulated in transcoder
procedure: (transcoder-error-handling-mode transcoder)
returns: the error-handling-mode symbol encapsulated in transcoder
libraries: (rnrs io ports), (rnrs)procedure: (native-transcoder)
returns: 返回本地 transcoder
libraries: (rnrs io ports), (rnrs)
The native transcoder is implementation-dependent and may vary by platform or locale.
procedure: (latin-1-codec)
returns: a codec for ISO 8859-1 (Latin 1) character encodings
procedure: (utf-8-codec)
returns: a codec for Unicode UTF-8 character encodings
procedure: (utf-16-codec)
returns: a codec for Unicode UTF-16 character encodings
libraries: (rnrs io ports), (rnrs)syntax: (eol-style symbol)
returns: symbol
libraries: (rnrs io ports), (rnrs)
symbol
必须是 lf, cr, nel, ls, crlf, crnel, none
之一。(eol-style symbol)
表达式与 (quote symbol)
是等价的,除了前者在宏展开期会检查 symbol
是否是合法的符号。另外,eol-style
宏提供了有用的文档。
(eol-style crlf) => crlf
(eol-style lfcr) => syntax violation
procedure: (native-eol-style)
returns: the native eol style
libraries: (rnrs io ports), (rnrs)
The native eol style is implementation-dependent and may vary by platform or locale.
syntax: (error-handling-mode symbol)
returns: symbol
libraries: (rnrs io ports), (rnrs)
symbol must be one of the symbols ignore
, raise
, or replace
. The expression (error-handling-mode symbol)
is equivalent to the expression (quote symbol)
except that the former checks at expansion time that symbol is one of the error-handling-mode symbols. The error-handling-mode syntax provides useful documentation as well.
(error-handling-mode replace) => replace
(error-handling-mode relpace) => syntax violation