Handbook
Glossary
detect-byte-array ( bytes -- encoding )
Vocabulary
io
.
encodings
.
detect
Inputs
bytes
an
object
Outputs
encoding
an
object
Definition
USING:
combinators
io.encodings.binary
io.encodings.detect.private
io.encodings.utf16
io.encodings.utf32
io.encodings.utf8
kernel
namespaces
sequences
;
IN:
io.encodings.detect
:
detect-byte-array
( bytes -- encoding )
{
{
[
dup
B{
0 0 254 255
}
head?
]
[
drop
utf32be
]
}
{
[
dup
B{
255 254 0 0
}
head?
]
[
drop
utf32le
]
}
{
[
dup
B{
254 255
}
head?
]
[
drop
utf16be
]
}
{
[
dup
B{
255 254
}
head?
]
[
drop
utf16le
]
}
{
[
dup
B{
239 187 191
}
head?
]
[
drop
utf8
]
}
{
[
dup
B{
60 63 120 109 108
}
head?
]
[
detect-xml-prolog
]
}
{
[
0
over
member?
]
[
drop
binary
]
}
{
[
dup
empty?
]
[
drop
utf8
]
}
{
[
dup
valid-utf8?
]
[
drop
utf8
]
}
[
drop
default-encoding
get
]
}
cond
;