whiteleaf7 / narou

Narou.rb - 小説家になろうのダウンローダ&縦書き整形&管理アプリ。Kindle(などの電子書籍端末)でなろうを読む場合に超便利です!
Other
483 stars 56 forks source link

変換できない[解決済み] #395

Closed U5376 closed 2 years ago

U5376 commented 2 years ago

[2022-01-31 20:21:19] ERROR ArgumentError: invalid byte sequence in UTF-8\n\tC:/ Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.0/lib/narou_logger.rb:187:in `embe d_timestamp'

[21:08:31] ID:12 リアデイルの大地にて【Web版】 の変換を開始 [21:08:34] 小説状態の調査結果を 調査ログ.txt に出力しました(エラー:3件、警告:0件、INFO:6件) [21:08:34] 縦書用の変換が終了しました [21:08:34] AozoraEpub3でEPUBに変換しています. [21:08:35] C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/narou_logger.rb:187:in sub': invalid byte sequence in UTF-8 (ArgumentError) [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/narou_logger.rb:187:inembed_timestamp' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/narou_logger.rb:166:in append_log' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/web/streaminglogger.rb:78:inwrite' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/novelconverter.rb:194:in puts' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/novelconverter.rb:194:intxt_to_epub' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/novelconverter.rb:315:in convert_txt_to_ebook_file' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:300:inconvert_txt_to_ebook_file' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/commandbase.rb:152:in call' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/commandbase.rb:152:inhook_call' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:252:in block in convert_novel_main' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:248:ineach' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:248:in convert_novel_main' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:201:inblock (2 levels) in convert_novels' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/mixin/locker.rb:26:in lock' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:200:inblock in convert_novels' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:199:in each' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:199:inwith_index' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:199:in convert_novels' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:159:inblock in main' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:152:in each' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:152:inmain' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:133:in execute' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/commandbase.rb:125:inexecute!' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/commandbase.rb:134:in execute!' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/command/convert.rb:123:inblock in execute!' [21:08:35] from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/narou-3.8.1/lib/worker.rb:49:in `block (3 levels) in start'

U5376 commented 2 years ago

javaアップデートしたあと解決した

kubo commented 2 years ago

[2022-01-31 20:21:19] ERROR ArgumentError: invalid byte sequence in UTF-8

~このエラーはおそらくは java.exe が実行できなくて cmd.exe がシフトJISでエラーメッセージを出しているのに、~(追記: Java 18 からパイプに対する標準出力がShift_JISになったのに)Helper::AsyncCommand.exec() の中で標準出力・標準エラーを以下のように UTF-8 決め打ちにしているせいだと思う。

https://github.com/whiteleaf7/narou/blob/1b07ae1ae017a581bc987622ba9dcd26728cf28c/lib/helper.rb#L422-L423

String#force_encoding(...) した後に String#valid_encoding? で本当に UTF-8 かどうかチェックして、UTF-8 じゃなかったら Encoding::Windows_31J (もしくは Encoding.find('locale'))に対して同様のことを行なってみるとか?

ndxbn commented 2 years ago

@U5376 解決済みであれば、Close していただけませんか?