Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incompatible character encodings: UTF-8 and Windows-31J #2

Open
N1nj4R4bb1D opened this issue Dec 31, 2015 · 4 comments
Open

incompatible character encodings: UTF-8 and Windows-31J #2

N1nj4R4bb1D opened this issue Dec 31, 2015 · 4 comments

Comments

@N1nj4R4bb1D
Copy link

wolftrans-0.2.0/lib/wolftrans/patch_text.rb:254:in `block (2 levels) in process_patch_file': incompatible character encodings: UTF-8 and Windows-31J (Encoding::CompatibilityError)

Encountered this problem with one game. I fixed it for myself by cobbling together an additional exception handling in patch_text.rb:254

begin
    output << "> CONTEXT " << context.to_s << " < UNTRANSLATED\n"
rescue => e
    if context.to_s.encoding != output.encoding
        output << context.to_s.encode!(output.encoding) << " < UNTRANSLATED\n"
    else
        raise e
    end
end
@elizagamedev
Copy link
Owner

Hmm, what OS are you running? And if you're running Windows, is your system codepage set to 932 (Japanese) by chance?

@N1nj4R4bb1D
Copy link
Author

Windows 10 (64-bit) and indeed language for non-Unicode programs is set to Japanese (which is required to run Japanese games in many cases). What was interesting with this encounter was that it came up with only one game from those i tested (i can recheck with different locale if you want).

@elizagamedev
Copy link
Owner

No thanks, I think I've figured it out. I was a bit sloppy and assumed that Ruby would be using UTF-8 for string literals, but it seems it uses the encoding of the source file, which makes sense. However, if you don't specify in the source file that it's encoded in UTF-8, it assumes the system codepage (which in your case was CP932) which it can't concatenate with the strings that it read from the files which it explicitly encoded to UTF-8. (It worked for me because my codepage is UTF-8.)

I think I'm doing a poor job of explaining this, but I'm about to merge your pull request with my own code and that should hopefully be a bit clearer.

@xephael
Copy link

xephael commented Jun 16, 2016

I'm getting a very similar error,
"E:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wolftrans-0.2.0/lib/wolfrpg/filecoder.rb:86:in `encode': incomplete "\x81" on Windows-31J (Encoding::InvalidByteSequenceError)"
My non-Unicode language is set to Japanese, I'm not sure if the project has been abandoned at this point, but is there anything I can do about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants