Created
July 7, 2014 15:18
-
-
Save paneq/0ecfc96c0d093a97e0e7 to your computer and use it in GitHub Desktop.
slicing ruby string to bytes (because APNS) and making it still look good
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
"777żółć".byteslice(0,6).scrub("") | |
"777żółć".byteslice(0,7).scrub("") | |
"777żółć".byteslice(0,8).scrub("") | |
"777żółć".byteslice(0,9).scrub("") |
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
[20] pry(main)> "777żółć".byteslice(0,6).scrub("") | |
=> "777ż" | |
[21] pry(main)> "777żółć".byteslice(0,7).scrub("") | |
=> "777żó" | |
[22] pry(main)> "777żółć".byteslice(0,8).scrub("") | |
=> "777żó" | |
[23] pry(main)> "777żółć".byteslice(0,9).scrub("") | |
=> "777żół" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment