DDCODE

Share programming skills from Magic Oriental

upArrow

After ruby reads txt, the Chinese characters in txt are scrambled

 May 11, 2019   question, ruby

Ruby reads Chinese garbled code in txt after txt

In this case, the encoding of the text file is usually inconsistent with the system encoding. You need to figure out what the encoding of the text file is first, and then

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

Related Posts:

  • How to merge the words in a.txt and b.txt into c.txt…
  • Why do you write mysql with Chinese characters that…
  • Why do you write mysql with Chinese characters that…
  • How to Write Content "Hello Process" into File f.txt…
  • Ios swift reads files containing Chinese characters
  • How does ruby read the scrambled data in mysql…
  • How does ruby read the scrambled data in mysql…
  • Brew install ruby successfully installed ruby-2.2.3…
  • PHP base64_encode encrypts Chinese character…
<< Why do you want to have to_s,to_str,inspect these three functions at the same time in Ruby? Why is nil.inspect “nil” On gem >>

Related Posts:

  • How to merge the words in a.txt and b.txt into c.txt…
  • Why do you write mysql with Chinese characters that…
  • Why do you write mysql with Chinese characters that…
  • How to Write Content "Hello Process" into File f.txt…
  • Ios swift reads files containing Chinese characters
  • How does ruby read the scrambled data in mysql…
  • How does ruby read the scrambled data in mysql…
  • Brew install ruby successfully installed ruby-2.2.3…
  • PHP base64_encode encrypts Chinese character…

Tags

Android android-studio apache c c++ centos Css css3 Database Docker Eclipse Express Front end git GitHub golang Html html5 Ios java javascript Jquery Laravel linux macos mongodb mysql Nginx node.js npm objective-c php Programmer python redis ruby shell Spring Sql Swift ubuntu vim vue.js Web xcode

Powered by MyWiki WordPress Theme