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

Generated PACTs are stored with System default encoding #395

Closed
apf3l opened this issue Mar 27, 2017 · 3 comments
Closed

Generated PACTs are stored with System default encoding #395

apf3l opened this issue Mar 27, 2017 · 3 comments

Comments

@apf3l
Copy link

apf3l commented Mar 27, 2017

When I try to generate PACT files with the letters ä, ü, ö and ß. The files are stored in system default encoding and not as expected in UTF-8, so these letters are displayed wrong. Is it possible to force UTF-8 for the json-file generation or is this an issue?

Tested Consumer: pact-jvm-consumer-junit_2.11
Versions:

  • 3.5.0-beta.2
  • 3.5.0-beta.3

Tested OSs:

  • Windows 7 SP1 64-bit
    Fileformat: ANSI
  • SUSE Linux Enterprise Server 12 SP2
    Fileformat: ASCII
@gammabowl
Copy link
Contributor

gammabowl commented Apr 6, 2017

Checked on Mac. Added ä to value in a field and it shows up as shown below.

"response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "field1": "value\u00e4" },

Consumer:
pact-jvm-consumer-junit_2.11

Version:
3.5.0-beta.2

Tested OS:
macOS Sierra Version 10.12.3

Running a check on system default encoding, it shows as us-ascii:
$ file -I test_consumer-test_provider.json
test_consumer-test_provider.json: text/plain; charset=us-ascii

@uglyog
Copy link
Member

uglyog commented Apr 9, 2017

Does this issue also occur with version 3.3.7?

@uglyog
Copy link
Member

uglyog commented Apr 14, 2017

It was the Groovy JSON class that was encoding the non-ascii characters into the unicode escape sequences. I have switched to GSON, and the characters are now preserved.

As a side note, the unicode escapes are equivalent:

groovy:000> "value\u00e4"
===> valueä
groovy:000> "value\u00e4" == 'valueä'
===> true

it is just that they are not escaped correctly in the JSON file.

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