• 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: Japanese backslash [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Japanese backslash [SOLVED]


  • Subject: Re: Japanese backslash [SOLVED]
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 23 Apr 2007 11:32:46 -0700

On Apr 23, 2007, at 7:16 AM, Mark J. Reed wrote:

I'm still surprised that you have to use a 0x80 to get a backslash to
work in a shell command in the Japanese locale.  I thought those
commands ignored locale settings...

The difficulty in this case is the conversion from "string" to Unicode text, since "do shell script" transcodes its input to UTF-8. Since the input is a "string" type, it's encoded using the primary encoding -- in this case, MacJapanese -- and the converter knows perfectly well that 0x80 in MacJapanese is a backslash, so it comes out as U+005C, a backslash. If, however, you use 0x5C then the converter knows equally well that that's a yen mark in MacJapanese, so it comes out as U+00A5, or 0xC2A5 in UTF-8, which the shell then chokes on.


Astute readers will have realized that this presents another workaround to the problem: use a Unicode backslash. This has the advantage of working the same world-wide, unlike the "ASCII character" solution. Any of these should do the trick:

	set backslash to «data utxtFEFF005C» as Unicode text
	set backslash to «data ut16005C» as Unicode text
	set backslash to «data utf85C» as Unicode text

As for commands ignoring locale or not, that's up to the command and the setting of the LANG environment variable. Some of them pay attention, some don't.

The escape character in Japanese was never supposed to be a yen mark -- it wound up that way because of how AppleScript was written and MacJapanese is defined. In other words, it was a bug. Tiger actually accepts either one, but will turn it into a backslash when you compile. This is mentioned in the 10.4 release notes <http://developer.apple.com/releasenotes/AppleScript/RN-AppleScript/index.html > under bug 3765766. A future release will only accept backslash.


--Chris Nebel AppleScript Engineering

_______________________________________________
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: 
 >Re: Japanese backslash [SOLVED] (From: email@hidden)
 >Re: Japanese backslash [SOLVED] (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Japanese backslash
  • Next by Date: Re: Japanese backslash
  • Previous by thread: Re: Japanese backslash [SOLVED]
  • Next by thread: File kind not consistent
  • Index(es):
    • Date
    • Thread