Encoding problem, YARD and JSON

I have a Hash object I am trying to convert to JSON using the `json` gem.
Using #to_json I am getting this error:

    in `encode': "\xC3" from ASCII-8BIT to UTF-8
(Encoding::UndefinedConversionError)

Most of the content of that hash is being extracted from the YARD api.

Can anyone offer any idea on what the problem might be and how to fix?

To me it sounds as if the particular String in question was obtained
binary from the source (yard api probably) and there is a value which
cannot be converted to UTF8 (maybe because it is > 0x7F). You could
try correct encodings when fetching or force a particular encoding
(e.g. one of the latin 8bit encodings) - if you _know_ the encoding.

Kind regards

robert

···

On Sun, Dec 18, 2011 at 6:23 PM, Intransition <transfire@gmail.com> wrote:

I have a Hash object I am trying to convert to JSON using the `json` gem.
Using #to_json I am getting this error:

in \`encode&#39;: &quot;\\xC3&quot; from ASCII\-8BIT to UTF\-8

(Encoding::UndefinedConversionError)

Most of the content of that hash is being extracted from the YARD api.

Can anyone offer any idea on what the problem might be and how to fix?

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

I ended up using #force_encoding to UTF-8 (and duping to unfreeze) every
value. Guess I'll report it as a YARD issue and see what they say.

Thanks.