mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-07 07:31:12 +08:00
Added an error message suggesting to specify the character encoding option
This commit is contained in:
parent
801c2a4920
commit
74f7a2435d
@ -102,8 +102,17 @@ module YouPlot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def read_dsv(input)
|
def read_dsv(input)
|
||||||
input = input.dup.force_encoding(options[:encoding]).encode('utf-8') if options[:encoding]
|
if options[:encoding]
|
||||||
DSV.parse(input, options[:delimiter], options[:headers], options[:transpose])
|
input.force_encoding(options[:encoding])
|
||||||
|
.encode!('utf-8')
|
||||||
|
end
|
||||||
|
begin
|
||||||
|
DSV.parse(input, options[:delimiter], options[:headers], options[:transpose])
|
||||||
|
rescue CSV::MalformedCSVError => e
|
||||||
|
warn 'Failed to parse the text. '
|
||||||
|
warn 'Please try to set the correct character encoding with --encoding option.'
|
||||||
|
raise e
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_plot
|
def create_plot
|
||||||
|
Loading…
Reference in New Issue
Block a user