core :: ISO88591Codec :: defaultinit
core $ ISO88591Codec :: SELF
Type of this instance, automatically specialized in every classcore $ ISO88591Codec :: add_char_to
Adds a charc
to bytes s
core $ ISO88591Codec :: add_string_to
Adds a strings
coded as the supported encoding to b
core $ ISO88591Codec :: char_max_size
Maximum size of acharacter
in supported encoding
core $ ISO88591Codec :: codet_size
Size of a codet for the target encodingcore $ ISO88591Codec :: decode_char
Decodes a char fromb
to a Unicode code-point
core $ ISO88591Codec :: decode_string
Decodes a stringb
to UTF-8
core $ ISO88591Codec :: encode_char
Transformsc
to its representation in the format of self
core $ ISO88591Codec :: encode_string
Transformss
to the format of self
core $ ISO88591Codec :: is_valid_char
Is the sequence of bytes inns
at position
a valid Char ?
core $ ISO88591Codec :: max_lookahead
How many lookaheads might be required to decode a single char ?core :: Codec :: add_char_to
Adds a charc
to bytes s
core :: Codec :: add_string_to
Adds a strings
coded as the supported encoding to b
core :: Codec :: char_max_size
Maximum size of acharacter
in supported encoding
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Codec :: decode_char
Decodes a char fromb
to a Unicode code-point
core :: Codec :: decode_string
Decodes a stringb
to UTF-8
core :: Codec :: defaultinit
core :: ISO88591Codec :: defaultinit
core :: Object :: defaultinit
core :: Codec :: encode_char
Transformsc
to its representation in the format of self
core :: Codec :: encode_string
Transformss
to the format of self
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Codec :: is_valid_char
Is the sequence of bytes inns
at position
a valid Char ?
core :: Codec :: max_lookahead
How many lookaheads might be required to decode a single char ?core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).
private class ISO88591Codec
super Codec
redef fun char_max_size do return 1
redef fun codet_size do return 1
redef fun max_lookahead do return 1
redef fun encode_char(c) do
var ns = new CString(c.u8char_len)
add_char_to(c, ns)
return ns
end
redef fun add_char_to(c, stream) do
var cp = if c.code_point <= 255 then c else '?'
stream[0] = cp.code_point
return 1
end
redef fun encode_string(s) do
var ns = new Bytes.with_capacity(s.byte_length)
add_string_to(s, ns)
return ns
end
redef fun add_string_to(s, b) do
var pos = 0
for i in s.chars do
var cp = i.code_point
if cp <= 255 then
b[pos] = cp
else
b[pos] = 0x3F
end
pos += 1
end
return pos
end
redef fun is_valid_char(ns, len) do
return 0
end
redef fun decode_char(b) do
return b[0].to_i.code_point
end
redef fun decode_string(b, len) do
var buf = new Bytes.with_capacity(len)
for i in [0 .. len[ do buf.add_char(b[i].to_i.code_point)
return buf.to_s
end
end
lib/core/codecs/iso8859_1.nit:21,1--75,3