• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
"

--
Take Care,
Chris

 _______________________________________________
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

  • Follow-Ups:
    • Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
      • From: Shane Stanley <email@hidden>
References: 
 >Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem? (From: quark67 <email@hidden>)
 >Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem? (From: Emmanuel LEVY <email@hidden>)
 >Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem? (From: quark67 <email@hidden>)
 >Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem? (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
  • Next by Date: Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
  • Previous by thread: Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
  • Next by thread: Re: Strange behavior with do shell script, the Unix-command sed and "»" or "«". Encoding problem?
  • Index(es):
    • Date
    • Thread