Created
August 9, 2016 23:51
-
-
Save dtakahas/dcf478cd3f68420dd02b2810c78bb55f to your computer and use it in GitHub Desktop.
Ruby String Encoding
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
2.1.5 :001 > utf = "".force_encoding("UTF-8") | |
=> "" | |
2.1.5 :002 > utf.encoding | |
=> #<Encoding:UTF-8> | |
2.1.5 :003 > ascii = "".force_encoding("ASCII-8BIT") | |
=> "" | |
2.1.5 :004 > ascii.encoding | |
=> #<Encoding:ASCII-8BIT> | |
2.1.5 :005 > example = "thisIsMyPath".force_encoding("UTF-8") | |
=> "thisIsMyPath" | |
2.1.5 :006 > example.encoding | |
=> #<Encoding:UTF-8> | |
2.1.5 :007 > example1 = ascii + example | |
=> "thisIsMyPath" | |
2.1.5 :008 > example2 = utf + example | |
=> "thisIsMyPath" | |
2.1.5 :009 > example1.encoding | |
=> #<Encoding:ASCII-8BIT> | |
2.1.5 :010 > example2.encoding | |
=> #<Encoding:UTF-8> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment