lzakharov / csv2md

Command line tool for converting CSV files into Markdown tables.
MIT License
102 stars 8 forks source link

set encoding to UTF-8 (for special characters) #7

Closed BrianInGermany closed 4 years ago

BrianInGermany commented 4 years ago

tables with "ä" "ö" etc. are not generating correctly.

lzakharov commented 4 years ago

@DarmstadtBri, thanks for the contribution! If not difficult, send a minimal example with expected and actual results.


It seems to be working fine:

Input:

a,b
ä,ö

Output:

| a | b |
| - | - |
| ä | ö |
BrianInGermany commented 4 years ago

Hi Lev,

Thanks for writing the library! Attached is a sample table and result. Maybe you could add a parameter for encoding.

Another error: If the CSV contains empty lines, it writes an empty markdown table.

Cheers,

Brian

word;status
Ãœber;bad
Redefreiheit;good
Fußball;bad
östlich;bad
Fähre;bad
noUmlaut;good
Weizen;good
Korn;good
BrianInGermany commented 4 years ago

Original CSV:

word;status Über;bad Redefreiheit;good Fußball;bad östlich;bad Fähre;bad noUmlaut;good Weizen;good Korn;good

BrianInGermany commented 4 years ago

Hi Lev, Thanks for writing the library! Attached is a sample table and result. Maybe you could add a parameter for encoding. Another error: If the CSV contains empty lines, it writes an empty markdown table. Cheers, Brian | word;status | | ----------------- | | Über;bad | | Redefreiheit;good | | Fußball;bad | | östlich;bad | | Fähre;bad | | noUmlaut;good | | Weizen;good | | Korn;good |

I have opened a separate issue for the ";" delimiter not working.

lzakharov commented 4 years ago

It still working for me fine (with version 1.1.2):

csv2md a.csv -d ";" > a.md

Original CSV and result: archive.zip.

Maybe you need check encoding on your host machine?

BrianInGermany commented 4 years ago

It still working for me fine:

csv2md a.csv -d ";" > a.md

Original CSV and result: archive.zip.

Maybe you need check encoding on your host machine?

Aha. I did not save to file, but copied out of the console

lzakharov commented 4 years ago

It still working for me fine:

csv2md a.csv -d ";" > a.md

Original CSV and result: archive.zip. Maybe you need check encoding on your host machine?

Aha. I did not save to file, but copied out of the console

Hm, maybe you have to set encoding to UTF-8 in your terminal:)

BrianInGermany commented 4 years ago

Strange, even when I write to file I get this on windows: mdTable.txt

word status
Über bad
Redefreiheit good
Fußball bad
├╢stlich bad
Fähre bad
noUmlaut good
Weizen good
Korn good
BrianInGermany commented 4 years ago

Strange, even when I write to file I get this on windows: mdTable.txt

word status Über bad Redefreiheit good Fußball bad östlich bad Fähre bad noUmlaut good Weizen good Korn good

The symbols have changed strangely.

lzakharov commented 4 years ago

I'm totally sure that Windows tries to write the result with it's own encoding. That's why you get such result. I've opened my a.md with win-1251 encoding and got the same strange symbols. Unfortunately, I haven't used Windows for five years and don’t know how to help you. Maybe you need to change global system encoding to UTF-8.

BrianInGermany commented 4 years ago

I'm totally sure that Windows tries to write the result with it's own encoding. That's why you get such result. I've opened my a.md with win-1251 encoding and got the same strange symbols. Unfortunately, I haven't used Windows for five years and don’t know how to help you. Maybe you need to change global system encoding to UTF-8.

Ok, that could well be the cause. Thanks for the help.

BrianInGermany commented 4 years ago

Tried it on another windows computer even, and it is working fine. Must be a setting on my other machine.