Created
June 8, 2012 16:32
-
-
Save buzztaiki/2896693 to your computer and use it in GitHub Desktop.
Patch for migemo on ruby 1.9 more
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
| diff --git a/migemo-dict.rb b/migemo-dict.rb | |
| index 61f60ad..e44e6d1 100644 | |
| --- a/migemo-dict.rb | |
| +++ b/migemo-dict.rb | |
| @@ -33,8 +33,14 @@ class MigemoDictItem | |
| end | |
| class MigemoDict | |
| + class << self | |
| + def open(filename) | |
| + File.open(filename, 'r', :external_encoding => __ENCODING__) | |
| + end | |
| + end | |
| + | |
| def initialize (filename) | |
| - @dict = File.new(filename) | |
| + @dict = MigemoDict.open(filename) | |
| end | |
| private | |
| @@ -57,7 +63,7 @@ end | |
| class MigemoStaticDict < MigemoDict | |
| def initialize (filename) | |
| super(filename) | |
| - @index = File.new(filename + ".idx").read.unpack "N*" | |
| + @index = MigemoDict.open(filename + ".idx").read.unpack "N*" | |
| end | |
| private | |
| @@ -106,8 +112,8 @@ end | |
| class MigemoDictCache | |
| def initialize (filename) | |
| - @dict = File.new(filename) | |
| - @index = File.new(filename + ".idx").read.unpack "N*" | |
| + @dict = MigemoDict.open(filename) | |
| + @index = MigemoDict.open(filename + ".idx").read.unpack "N*" | |
| end | |
| def decompose (idx) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment