Changing text to ascii codes

I’m trying to set up an AppleScript Studio app, and I’m wondering if there’s a way to get applescript to copy text as ASCII values, or convert it to them… in just AppleScript. There should be, shouldn’t there? I also need to be able to convert from ascii values to text. If you can give me any help, I’d appreciate it. Thanks.

Here’s a sample you can cut & paste into the Script Editor:

set aaa to ASCII character 65 
 -->  "A" 
set bbb to ASCII number "A" 
 --> 65 
set bbb to ASCII number "ABC" 
 -->ALSO  65 

Note the last one–only the first char. is considered

–tet

ASCII character: Convert a number to an ASCII character
	ASCII character  small integer  -- the ASCII code of the specified character
	Result:   string  -- the character

ASCII number: Convert a character to its ASCII numeric value
	ASCII number  string  -- the character
	Result:   small integer  -- the ASCII code of the specified character

from the standard additions dictionary.

Hey

I have come up with an answer you may be looking for:

This is a test script i wrote in Applescript, but it should definately work in Applescript Studio, also.

--begin

set stuff to "I want this to be ASCII Code"
set stuff_ascii_numbers to {}
set stuff_ascii_html to ""


--getting list of all the ascii numbers of every character
repeat with a from 1 to the count of characters in stuff
	
	set the end of stuff_ascii_numbers to (ASCII number of (character a of stuff))
	
end repeat

--adding "&#" to beginning of every number and ";" to the end
repeat with c from 1 to the count of stuff_ascii_numbers
	
	set stuff_ascii_html to stuff_ascii_html & "&#" & ((item c of stuff_ascii_numbers) as text) & ";"
	
end repeat

display dialog (stuff as text) & return & return & "Copy this:" default answer stuff_ascii_html as string

--end

You can set the variable “stuff” to what you would like to translate, and the result
is a dialog box with the ascii code ready for you to copy and paste.

You can edit this freely if you wish. I can see many applications for this in Applescript Studio.

Actually, disregard that script. I just noticed that some characters are missing from my script when I copied an pasted it.

I will upload a text file to my website where you can download it.

From there you can copy and paste it into your script.

http://www.raymondlewisjones.com/Downloads/sample.sit

Actually, disregard that script. I just noticed that some characters are missing from my script when I copied an pasted it.

I will upload a text file to my website where you can download it.

From there you can copy and paste it into your script.

http://www.raymondlewisjones.com/Downloads/sample.sit