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

use force_encoding instread of encode! to avoid UndefinedConversionError #27076

Merged
merged 1 commit into from
Nov 17, 2016

Commits on Nov 17, 2016

  1. use force_encoding instread of encode! to avoid `UndefinedConvers…

    …ionError`
    
    `PG::TextEncoder::Array#encode` returns the encoded value with `ASCII-8BIT`.
    But in some cases, trying to convert `ASCII-8BIT` to `UTF-8` cause an error.
    
    ```ruby
    "{\xE3\x83\x95\xE3\x82\xA1\xE3\x82\xA4\xE3\x83\xAB}".encode!(Encoding::UTF_8)
    # => Encoding::UndefinedConversionError: "\xE3" from ASCII-8BIT to UTF-8
    ```
    Should use `force_encoding` to avoid this error.
    
    Follow up to 7ba3a48
    
    Ref: rails#23619 (comment)
    y-yagi committed Nov 17, 2016
    Configuration menu
    Copy the full SHA
    70878b6 View commit details
    Browse the repository at this point in the history