Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
- Subject: Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
- From: Axel Luttgens <email@hidden>
- Date: Wed, 22 Oct 2014 01:57:53 +0200
Le 21 oct. 2014 à 18:08, quark67 a écrit :
> I prefer an AppleScript fix or workaround. What is special in AppleScript with "«" and "»" ?
They are outside of the ASCII character set; the shell thus needs some hints for their handling.
Run this one in AppleScript Editor:
do shell script "locale"
You'll notice that by default the shell, as invoked by AppleScript, relies on a "traditional" C encoding.
But strings as encoded by AppleScript are UTF-8 ones. This is thus a first source of discrepancy.
Additionally, but this is more rhetorical in this precise case, if some command appears to "works well" in the shell, it is always a good idea to make use of AppleScript's "quoted form of" property of any potentially arbitrary text liable to be passed as an argument to a shell command thru AppelScript's command "do shell script".
So, if this one works for you in Terminal.app:
echo "Bonjour « hello » world" | sed -E 's/ [»]/_»/g'
this one should be fine in AppleScript too:
do shell script "export LANG=fr_FR.UTF-8; echo " & quoted form of "Bonjour « hello » world" & " | sed -E " & quoted form of "s/ [»]/_»/g"
I'm assuming, from one of your previous post, that you are running a french system.
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden