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

ipconfig /all,got encoding error on non-english windows #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

debbbbie
Copy link

@debbbbie debbbbie commented Apr 3, 2014

ipconfig /all got an error: invalid byte sequence in UTF-8
when windows is non English Enviroment.

Fix it like this : http://stackoverflow.com/a/9420531/1355590

encoding_options = {
:invalid => :replace, # Replace invalid byte sequences
:undef => :replace, # Replace anything not defined in ASCII
:replace => '', # Use a blank for those replacements
:universal_newline => true # Always break lines with \n
}
non_ascii_string.encode(Encoding.find('ASCII'), encoding_options)

`ipconfig /all` got an error: `invalid byte sequence in UTF-8`
when windows is non English Enviroment.

Fix it like this : http://stackoverflow.com/a/9420531/1355590

  encoding_options = {
    :invalid           => :replace,  # Replace invalid byte sequences
    :undef             => :replace,  # Replace anything not defined in ASCII
    :replace           => '',        # Use a blank for those replacements
    :universal_newline => true       # Always break lines with \n
  }
  non_ascii_string.encode(Encoding.find('ASCII'), encoding_options)
@sporkmonger
Copy link
Owner

Wow there are some serious edge cases on this stuff.

@sporkmonger
Copy link
Owner

Unfortunately, the test failures on this commit look legitimate. All tests need to pass before I can merge 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

Successfully merging this pull request may close these issues.

2 participants