You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently developing an application where string encoding is important, and I've discovered that JSON.parse unexpectedly alters the encoding of the passed string.
Here's a simple code snippet to reproduce the issue:
I would expect JSON.parse not to alter the original encoding of the passed string, unless it is necessary for the parsing operation.
Current Workaround
Currently, I'm using the dup method to create a copy of the original string before parsing it to prevent the original string's encoding from being altered:
JSON.parse(str.dup)
The text was updated successfully, but these errors were encountered:
Description
I am currently developing an application where string encoding is important, and I've discovered that JSON.parse unexpectedly alters the encoding of the passed string.
Here's a simple code snippet to reproduce the issue:
This code yields the following output:
As shown above, the encoding of the string str changes from 'ASCII-8BIT' to 'UTF-8' after the JSON.parse operation.
My current environment is as follows:
Expected Behavior
I would expect JSON.parse not to alter the original encoding of the passed string, unless it is necessary for the parsing operation.
Current Workaround
Currently, I'm using the dup method to create a copy of the original string before parsing it to prevent the original string's encoding from being altered:
The text was updated successfully, but these errors were encountered: