• 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: Shane Stanley <email@hidden>
  • Date: Wed, 22 Oct 2014 09:59:14 +1100

On 22 Oct 2014, at 3:08 am, quark67 <email@hidden> wrote:

What is special in AppleScript with "«" and "»" ?

There's nothing special about them -- you will get the same problem with other Unicode characters. For example:

set r to do shell script "echo \"Bonjour “ hello ” world\" | sed -E 's/ [”]/_”/g'"

Returns:

Bonjour_‚ÄùÄú hello_‚ÄùÄù world

Nigel or one of the other sed users might explain why, but on the face of it Unicode characters are not being recognised as such.

If you're using Yosemite or Mavericks, you can use an AppleScript-only solution. In Yosemite:

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set theString to "Bonjour « hello » world"
set anNSString to current application's NSString's stringWithString:theString
set theString to (anNSString's stringByReplacingOccurrencesOfString:" [»]" withString:¬
"_»" options:(current application's NSRegularExpressionSearch) range:{0, length of theString}) as text

In Mavericks you'd have to wrap it in a Script Library.


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

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>)

  • 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