/code.cr Secret
Created
February 14, 2017 00:50
This file contains hidden or 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
pp string | |
string.each_byte do |byte| | |
p byte <= 0x1F | |
case byte | |
when '\t'.ord, ' '.ord, '"'.ord, '\\'.ord | |
io << '\\' | |
when byte <= 0x1F, 0x7F | |
raise ArgumentError.new("String contained invalid character #{byte.chr.inspect}") | |
end | |
io.write_byte byte | |
end |
This file contains hidden or 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
string # => "foo\u{0}bar" | |
false | |
false | |
false | |
true | |
false | |
false | |
false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment