• 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: Reformatting a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reformatting a string


  • Subject: Re: Reformatting a string
  • From: KOENIG Yvan <email@hidden>
  • Date: Fri, 27 Jan 2012 22:02:27 +0100

Le 27 janv. 2012 à 20:48, Michelle Steiner a écrit :

> On Jan 27, 2012, at 11:07 AM, Angelo wrote:
>
>> I need to take a long string string of letters numbers and colons and convert it to uppercase letters w/ no colons.
>> a2:fh:2f:vv:i1:q1   needs to be  A2FH2FVVI1Q1.
>
> set x to "a2:fh:2f:vv:i1:q1"
> set text item delimiters to {":"}
> set x to text items of x
> set text item delimiters to {""}
> set x to x as string
> set y to {}
> repeat with i from 1 to count of x
> 	set z to ASCII number of character i of x
> 	if z > 96 and z < 123 then
> 		copy (ASCII character of (z - 32)) to end of y
> 	else
> 		copy character i of x to end of y
> 	end if
> end repeat
> set y to y as string
>
>
> --> "A2FH2FVVI1Q1"
>
> -- Michelle

Hello Michelle

Your code assume that the original string contain only ASCII characters
Jon's one treat the ASCII range plus a short list of accented characters.

I used the Python handler (which I got here if I remeber well) because it treat a larger range of accented chars.

I'm not saying that one is better than the other one.
Just that when I don't know the exact contents of strings to treat, I choose the code supposed to be able to treat every case.
Old habit of an inhabitant of a country using several non ASCII characters.
My firstname is not KOENIG, it's KŒNIG.
I took the habit to replace it by ASCII characters because it was treated awfully when used in mails. I wrote 'was' but in fact from time to time the Œ continue to be replaced by fancy characters.

I'm curious to see how it will be treated this time ;-)

Yvan KOENIG (VALLAURIS, France) vendredi 27 janvier 2012 22:01:45


 _______________________________________________
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: Reformatting a string
      • From: KOENIG Yvan <email@hidden>
    • Re: Reformatting a string
      • From: Shane Stanley <email@hidden>
References: 
 >Reformatting a string (From: Angelo <email@hidden>)
 >Re: Reformatting a string (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Reformatting a string
  • Next by Date: Re: Reformatting a string
  • Previous by thread: Re: Reformatting a string
  • Next by thread: Re: Reformatting a string
  • Index(es):
    • Date
    • Thread