Created
November 1, 2011 06:38
-
-
Save shyouhei/1330056 to your computer and use it in GitHub Desktop.
Pathname's raising "invalid sequence"
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
# -*- coding: utf-8 -*- | |
require 'pathname' | |
s1 = File.dirname(__FILE__) | |
s2 = File.expand_path('ディレクトリ/ファイル', s1) | |
s3 = File.dirname(s2) | |
s4 = File.expand_path(s3) | |
p1 = Pathname(s2) | |
p2 = Pathname(s4) | |
p3 = p2.relative_path_from(p1) |
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
zsh % ruby -v bug.rb | |
ruby 1.9.3p0 (2011-10-30 revision 33569) [x86_64-linux] | |
/lib/ruby/1.9.1/pathname.rb:45:in `=~': invalid byte sequence in UTF-8 (ArgumentError) | |
from /lib/ruby/1.9.1/pathname.rb:45:in `chop_basename' | |
from /lib/ruby/1.9.1/pathname.rb:101:in `cleanpath_aggressive' | |
from /lib/ruby/1.9.1/pathname.rb:89:in `cleanpath' | |
from /lib/ruby/1.9.1/pathname.rb:450:in `relative_path_from' | |
from bug.rb:10:in `<main>' | |
zsh: exit 1 ruby -v bug.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment