PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > How to pass an UTF-8 string to a shell script and to save a file as UTF-8?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

How to pass an UTF-8 string to a shell script and to save a file as UTF-8?

Réponse
 
LinkBack Outils de la discussion
Vieux 07/12/2006, 22h53   #1
Charles A. Landemaine
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to pass an UTF-8 string to a shell script and to save a file as UTF-8?

I have a C++ program that sends a string encoded in UTF-8 to a shell
script. This shell script performs a text replacement in a text file
encoded in UTF-8. The command is like this:

%./TextProc new_string_here

Problem is that when I execute the C++ program, the shell script saves
the file as ISO-8859-1 instead of keeping the original character
encoding (UTF-8). And therefore, Latin/Asian characters are turnt into
squares.

Do you know how I could save my UTF-8 string in the same character set
all the way?
Thanks,

  Réponse avec citation
Vieux 07/12/2006, 23h33   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to pass an UTF-8 string to a shell script and to save a file as UTF-8?

On 7 Dec 2006 14:53:09 -0800, Charles A. Landemaine
<landemaine@gmail.com> wrote:
> I have a C++ program that sends a string encoded in UTF-8 to a shell
> script. This shell script performs a text replacement in a text file
> encoded in UTF-8. The command is like this:
>
> %./TextProc new_string_here
>
> Problem is that when I execute the C++ program, the shell script saves
> the file as ISO-8859-1 instead of keeping the original character
> encoding (UTF-8). And therefore, Latin/Asian characters are turnt into
> squares.
>
> Do you know how I could save my UTF-8 string in the same character set
> all the way?
> Thanks,
>

Make sure the shell script runs in a UTF-8 locale. Start it with
export LANG=en_US.utf8
or replace "en_US" with the appropriate language and country codes.


--
Ever wonder if taxation without representation might have been cheaper?
  Réponse avec citation
Vieux 07/12/2006, 23h37   #3
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to pass an UTF-8 string to a shell script and to save a file as UTF-8?

2006-12-7, 14:53(-08), Charles A. Landemaine:
> I have a C++ program that sends a string encoded in UTF-8 to a shell
> script. This shell script performs a text replacement in a text file
> encoded in UTF-8. The command is like this:
>
> %./TextProc new_string_here
>
> Problem is that when I execute the C++ program, the shell script saves
> the file as ISO-8859-1 instead of keeping the original character
> encoding (UTF-8). And therefore, Latin/Asian characters are turnt into
> squares.
>
> Do you know how I could save my UTF-8 string in the same character set
> all the way?

[...]

Not too sure what you mean, but no UTF-8 character other that
some of the ASCII ones are special to any shell. No shell will
do any conversion of charsets on its own.

You'll have to give more details about what commands are called
within your script and what you want to achieve.

--
Stéphane
  Réponse avec citation
Vieux 08/12/2006, 12h17   #4
Charles A. Landemaine
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to pass an UTF-8 string to a shell script and to save a file as UTF-8?

Bill Marcum wrote:
> Make sure the shell script runs in a UTF-8 locale. Start it with
> export LANG=en_US.utf8
> or replace "en_US" with the appropriate language and country codes.


Thank you guys! The shells weren't localized into UTF-8. Exporting the
LANG variable fixed it

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h15.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08301 seconds with 12 queries