• 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: Using AppleScript to Detect Nul Characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using AppleScript to Detect Nul Characters


  • Subject: Re: Using AppleScript to Detect Nul Characters
  • From: Bernardo Hoehl <email@hidden>
  • Date: Sat, 30 Apr 2005 14:01:56 -0300

Thanks Gnarlie, Jean-Baptiste and Kai,

I have come up with this simple script, using your tips:

(didn't know I could simply reffer to the Nul chars as ASCII character 0)

set thefile to (read (choose file))
set thelist to every character of thefile
repeat with i from 1 to the count of thelist
if text i of thelist is (ASCII character 0) then
beep
display dialog "Found an invalid character on position " & (i as text)
end if
end repeat

Thanks to you all for the help,

Bernardo

++++++++++++++++++++++++

On 30 Apr 2005, at 1:25 PM, kai wrote:

On Saturday, April 30, 2005, at 03:57 pm, Bernardo Hoehl wrote:

[snip]

As a novice high-level programmer, I did not know that every character is represented by a hex value, and that I had two "gremlins" in my Template text (used to send out the emails after text manipulation), I mean, I had two hex values = 00.

[snip]

As I move on forward with my learning, I am wondering if there is an "AppleScript way" I can use to detect these Gremlins, and so create a routine in my application to check the consistency of any text I use for sending out emails.

Do you mean something like this, Bernardo?

-----------------

to stripEveryCase of c from t
set d to text item delimiters
set text item delimiters to c
if (count t's text items) > 1 then
set t to t's text items
set text item delimiters to ""
set t to t as string
end if
set text item delimiters to d
t
end stripEveryCase

stripEveryCase of (ASCII character 0) from someText

-----------------

To test with a visible character:

-----------------

set someText to "Mary *had* a little lamb**"
stripEveryCase of "*" from someText
--> "Mary had a little lamb"

-----------------

If you just want to check for the presence of a particular character (but not remove it):

-----------------

(ASCII character 0) is in someText
--> true or false

-----------------

---
kai

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Using AppleScript to Detect Nul Characters
      • From: kai <email@hidden>
References: 
 >Re: Using AppleScript to Detect Nul Characters (From: kai <email@hidden>)

  • Prev by Date: Re: Using AppleScript to Detect Nul Characters
  • Next by Date: theText is empty. why?
  • Previous by thread: Re: Using AppleScript to Detect Nul Characters
  • Next by thread: Re: Using AppleScript to Detect Nul Characters
  • Index(es):
    • Date
    • Thread