aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rexml/encodings
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rexml/encodings')
-rw-r--r--lib/rexml/encodings/CP-1252.rb13
-rw-r--r--lib/rexml/encodings/ISO-8859-15.rb9
2 files changed, 15 insertions, 7 deletions
diff --git a/lib/rexml/encodings/CP-1252.rb b/lib/rexml/encodings/CP-1252.rb
index 51179f119f..29f94d3f8c 100644
--- a/lib/rexml/encodings/CP-1252.rb
+++ b/lib/rexml/encodings/CP-1252.rb
@@ -3,9 +3,15 @@
#
module REXML
module Encoding
- @@__REXML_encoding_methods = %q~
+ register( "CP-1252" ) do |o|
+ class << o
+ alias encode encode_cp1252
+ alias decode decode_cp1252
+ end
+ end
+
# Convert from UTF-8
- def encode content
+ def encode_cp1252(content)
array_utf8 = content.unpack('U*')
array_enc = []
array_utf8.each do |num|
@@ -54,7 +60,7 @@ module REXML
end
# Convert to UTF-8
- def decode(str)
+ def decode_cp1252(str)
array_latin9 = str.unpack('C*')
array_enc = []
array_latin9.each do |num|
@@ -93,6 +99,5 @@ module REXML
end
array_enc.pack('U*')
end
- ~
end
end
diff --git a/lib/rexml/encodings/ISO-8859-15.rb b/lib/rexml/encodings/ISO-8859-15.rb
index ce565e7dd5..3b0ac01d2f 100644
--- a/lib/rexml/encodings/ISO-8859-15.rb
+++ b/lib/rexml/encodings/ISO-8859-15.rb
@@ -3,9 +3,13 @@
#
module REXML
module Encoding
- @@__REXML_encoding_methods = %q~
+ register("ISO-8859-15") do |o|
+ alias encode to_iso_8859_15
+ alias decode from_iso_8859_15
+ end
+
# Convert from UTF-8
- def to_iso_8859_15 content
+ def to_iso_8859_15(content)
array_utf8 = content.unpack('U*')
array_enc = []
array_utf8.each do |num|
@@ -64,6 +68,5 @@ module REXML
end
array_enc.pack('U*')
end
- ~
end
end