Sed and UTF-8 encoding

In SSH (Putty) I am using a command to replace some text in a file that is encoded in UTF-8

for example

cd ~/public_html/app/Config; sed -i 's/ADDRESS_SSH/l'adresse à été correctement intégréé/g' param.php;

Everything is fine in the file, but when displayed in the browser the accents are strange When inspecting the param.php file, I found that its encoding changed from UTF-8

toEurope de L'Ouest

Similar issue for .xml file too

Any help on using sed without changing the encoding, or perhaps adding another ssh line to rencoding php and xml files to UTF-8?

Best wishes and thank you

+3


source to share


2 answers


It was on Putty config ==> Translation ==> Received data that supposedly was in character set ==> Select UTF-8 Best Regards



0


source


You must make sure that the issued command is sed

encoded UTF-8

.

You can do this in one of two ways:



  • Write a sed command to a file, make sure the file is UTF-8, and execute it as a script:

    file yourfile

    I have to say UTF-8 Unicode text

    .

    Then you can run bash yourfile

    .

  • Alternatively change your terminal and shell settings to UTF-8

    printf à | wc -c

    should say 2 and not 1.

    locale

    must specify "UTF-8" or "utf8" in the string LC_CTYPE

    .

    Then you can run sed command directly from the terminal command line.

+5


source







All Articles