Created
February 21, 2013 16:42
-
-
Save Quintus/5006071 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) 64-Bit Server VM 1.7.0_13-b20 [linux-amd64] | |
[12] pry(main)> str = "AA\xC3AA" | |
=> "AA\xC3AA" | |
[13] pry(main)> str.encoding | |
=> #<Encoding:UTF-8> | |
[14] pry(main)> str.force_encoding("BINARY") | |
=> "AA\xC3AA" | |
[15] pry(main)> str.encode("UTF-8") | |
Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8 | |
from org/jruby/RubyString.java:7563:in `encode' | |
[16] pry(main)> str.encode("UTF-8", :undef => :replace) | |
Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8 #<== Diese Exception darf nicht sein |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby 1.9.3p385 (2013-02-06 revision 39114) [x86_64-linux] | |
1] pry(main)> str = "AA\xC3AA" | |
=> "AA\xC3AA" | |
[2] pry(main)> str.force_encoding("BINARY") | |
=> "AA\xC3AA" | |
[3] pry(main)> str.encode("UTF-8") | |
Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8 | |
from (pry):3:in `encode' | |
[4] pry(main)> str.encode("UTF-8", :undef => :replace) | |
=> "AA?AA" #<== Das ist das korrekte Ergebnis |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment