vscode_rainbow_csv icon indicating copy to clipboard operation
vscode_rainbow_csv copied to clipboard

Bad encoding leads to unaligned cells

Open Chrismettal opened this issue 2 years ago • 2 comments

When the file you opened has chars that are badly encoded in it, the alignment will shift as if that char does not exist at all.

For example, the following string was saved with ANSI (Windows 1252) encoding:

This,is,a,header,with,°,bad,chars,°,sprinkled,throughout,
,,,,,,,,,,,
,,,,,,,,,,,

After opening it in VSCode, the default settings will try to open the file as UTF-8:

image

Obviously the real problem is opening the file with the wrong encoding, but trying to align the table regardless, because sometimes you just don't care if a single symbol is decoded correctly, the alignment will be off after each bad char:

image

While the problem does not start with the extension, maybe there is still a way to detect the bad char questionmark � during counting for alignment as well.

Chrismettal avatar Jan 03 '22 15:01 Chrismettal

Thanks for reporting. I agree that this is an issue, and this might actually be a special case of a more general problem, see #69

mechatroner avatar Jan 24 '22 05:01 mechatroner

You are right, I thought it was an issue of the > not being counted when padding other cells, but showing whitespace reveals that > just does not adhere to the fixed with font width like your referenced issue.

Well this is a difficult one to fix then.. Would need to add whitespace of a fixed width of the same size as the non-standard size character then..

image

image

Chrismettal avatar Jan 24 '22 15:01 Chrismettal