Created
December 29, 2014 21:06
-
-
Save headius/e626823606f4451540ff 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
#encoding: UTF-8 | |
require 'pathname' | |
path = '/tmp/INSERT_NON_ASCII_NAME' # just type in any non-ascii characters | |
pathname = Pathname.new(path) | |
begin | |
puts 'MKPATH' | |
# fails with IllegalArgumentException | |
pathname.mkpath | |
puts 'OK' | |
rescue => error | |
puts "ERROR: #{error.inspect}" | |
end | |
begin | |
puts 'OPEN' | |
# fails also, but target file is actually created (but empty) | |
File.open(pathname.to_path, "w") { |io| io << 'Hello' } | |
puts 'OK' | |
rescue => error | |
puts "ERROR: #{error.inspect}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment