Sed and UTF-8 encoding

前端 未结 2 1097
离开以前
离开以前 2020-12-19 14:56

In SSH (Putty) I\'m using a command to replace some text in a file which is encoded in UTF-8

For example

cd ~/public_html/app/Config; sed -i \'s/ADDRE

相关标签:
2条回答
  • 2020-12-19 15:31

    You have to ensure that the issued sed command is UTF-8 encoded.

    You can do this in one of two ways:

    1. Write the sed command to a file, ensure the file is UTF-8, and execute it as a script:

      file yourfile should say UTF-8 Unicode text.

      You can then run bash yourfile.

    2. Alternatively, change your terminal and shell settings to UTF-8

      printf à | wc -c must say 2, not 1.

      locale should list "UTF-8" or "utf8" in the LC_CTYPE line.

      You can then run the sed command straight from the terminal prompt.

    0 讨论(0)
  • 2020-12-19 15:47

    It was on Putty configuration ==> Translation ==> Received data assumed to be in which character set ==> Choose UTF-8 Best regards

    0 讨论(0)
提交回复
热议问题