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

Wierd behaviour on backslashes in literals #165

Open
mvanbrab opened this issue May 24, 2022 · 5 comments
Open

Wierd behaviour on backslashes in literals #165

mvanbrab opened this issue May 24, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@mvanbrab
Copy link

Found on version 5.0.0 and 4.15.0:

Single backslashes are eaten, double backslashes are output as double backslashes, triple backslashes are output as double backslahes.

A testcase is provided in attached file.

Remark: version 4.12.0 always output twice the number of backslashes in the input.

issue.zip

@DylanVanAssche
Copy link
Contributor

Hi @mvanbrab !

Do you get the same behavior if the data is in JSON?

@mvanbrab
Copy link
Author

mvanbrab commented May 24, 2022

Well no, but in equivalent JSON input I have to provide two backslashes where I mean one, so this is the input then and the output is OK (also contains the same amount of backslashes as the input), but that seems like a no-brainer to me...

[
  {
    "id": "1",
    "description": "One backslash:     \\."
  },
  {
    "id": "2",
    "description": "Two backslashes:   \\\\."
  },
  {
    "id": "3",
    "description": "Three backslashes: \\\\\\"
  },
  {
    "id": "4",
    "description": "A backslash before the '{': a ∈ ℝ⁺₀\\{1}."
  }
]```

@DylanVanAssche
Copy link
Contributor

Aha! That confirms my hypothesis: a few versions ago, we switched from Apache CSV to Open CSV to parse CSV files.
That library is probably eating the \ characters for lunch.

@DylanVanAssche
Copy link
Contributor

It seems that this is a common problem: https://dzone.com/articles/properly-handling-backslashes-using-opencsv

@DylanVanAssche
Copy link
Contributor

Tested the solution from dzone.com.
It works for this case but breaks other edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants