Home  >  Q&A  >  body text

ruby读取txt后,txt中的中文乱码

ruby 读取txt后 txt中的中文乱码

伊谢尔伦伊谢尔伦2759 days ago870

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-24 09:15:20

    This situation usually occurs when the encoding of the text file is inconsistent with the system encoding. You need to first figure out what the encoding of the text file is, and then

    File.read('your_file.txt', 'r:YOUR_ENCODING')

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-24 09:15:20

    Is it an encoding problem? Preferably encoded in UTF-8

    reply
    0
  • Cancelreply