method
to_iso_8859_15
v1_8_7_72 -
Show latest stable
- Class:
REXML::Encoding
to_iso_8859_15(content)public
Convert from UTF-8
# File lib/rexml/encodings/ISO-8859-15.rb, line 12
def to_iso_8859_15(content)
array_utf8 = content.unpack('U*')
array_enc = []
array_utf8.each do |num|
case num
# shortcut first bunch basic characters
when 0..0xA3; array_enc << num
# characters removed compared to iso-8859-1
when 0xA4; array_enc << '¤'
when 0xA6; array_enc << '¦'
when 0xA8; array_enc << '¨'
when 0xB4; array_enc << '´'
when 0xB8; array_enc << '¸'
when 0xBC; array_enc << '¼'
when 0xBD; array_enc << '½'
when 0xBE; array_enc << '¾'
# characters added compared to iso-8859-1
when 0x20AC; array_enc << 0xA4 # 0xe2 0x82 0xac
when 0x0160; array_enc << 0xA6 # 0xc5 0xa0
when 0x0161; array_enc << 0xA8 # 0xc5 0xa1
when 0x017D; array_enc << 0xB4 # 0xc5 0xbd
when 0x017E; array_enc << 0xB8 # 0xc5 0xbe
when 0x0152; array_enc << 0xBC # 0xc5 0x92
when 0x0153; array_enc << 0xBD # 0xc5 0x93
when 0x0178; array_enc << 0xBE # 0xc5 0xb8
else
# all remaining basic characters can be used directly
if num <= 0xFF
array_enc << num
else
# Numeric entity (&#nnnn;); shard by Stefan Scholl
array_enc.concat "&\##{num};".unpack('C*')
end
end
end
array_enc.pack('C*')
end Related methods
- Instance methods
- check_encoding
- decode_ascii
- decode_cp1252
- decode_eucjp
- decode_eucjp
- decode_iconv
- decode_sjis
- decode_sjis
- decode_unile
- decode_utf16
- decode_utf8
- encode_ascii
- encode_cp1252
- encode_eucjp
- encode_eucjp
- encode_iconv
- encode_sjis
- encode_sjis
- encode_unile
- encode_utf16
- encode_utf8
- encoding=
- from_iso_8859_15
- to_iso_8859_15
- Class methods
- apply
- encoding_method
- register