Skip to content

Instantly share code, notes, and snippets.

@headius
Created December 29, 2014 21:06
Show Gist options
  • Save headius/e626823606f4451540ff to your computer and use it in GitHub Desktop.
Save headius/e626823606f4451540ff to your computer and use it in GitHub Desktop.
#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