Ruby: how to add “# encoding: UTF-8” automatically?

前端 未结 6 1038
时光说笑
时光说笑 2020-12-05 00:21

Is there any gem which adds # encoding: UTF-8 to each Ruby file automatically?

Or is there any other way to prevent from the invalid multibyte cha

6条回答
  •  鱼传尺愫
    2020-12-05 00:56

    Adding a # encoding: UTF-8 to each Ruby file automatically makes only sense, when your files are really stored in UTF-8.

    If your files are encoded CP850 (AFAIK default in Windows) and you use Non-ASCII characters, you replace invalid multibyte char (US-ASCII) with invalid multibyte char (UTF-8).

    I would prefer a manual modification and check of each file, if it is really UTF-8.

提交回复
热议问题