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: Christopher Stone <email@hidden>
- Date: Wed, 22 Oct 2014 01:03:59 -0500
On Oct 21, 2014, at 18:57, Axel Luttgens <email@hidden> wrote:... do shell script "locale"
... ______________________________________________________________________
Hey Axel,
Many thanks!
If I knew all of that before it silently slipped through the splinters of my mind's eye. :)
Playing around a bit...
It's worth running `locale` in the Terminal for contrast:
LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL=
* On my U.S. English System.
A couple of worthwhile pointers here.
do shell script "export LC_ALL=en_US.UTF-8; locale;"
It looks like this will solve some of the problems I've had from time to time.
`gsed` (4.2.2) handles this encoding issue without external adjustment:
set _text to "Bonjour « hello » world" do shell script "echo " & quoted form of _text & " | /opt/local/bin/gsed -r 's/[«»]/•/g'"
--> "Bonjour • hello • world"
I found a localization-sensitive method on one of the Alfred forums which should please Yvan.
do shell script " export LC_ALL=\"$(defaults read -g AppleLocale).UTF-8\"; echo " & quoted form of _text & " | sed -E 's/[«»]/•/g'; locale "
--
|
_______________________________________________
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