unfortunately the opposite perl routine uses utf-8
set b to "Et øjeblik!...Værsgo! For det første er igangværende direkte , så er der ikke mere gyrate til højre og der har vi det hitte en oversætter!"
do shell script "perl -e 'use URI::Escape; print uri_escape(\"" & b & "\")';"
--> Et%20%C3%B8jeblik!...V%C3%A6rsgo!%20For%20det%20f%C3%B8rste%20er%20igangv%C3%A6rende%20direkte%20%2C%20s%C3%A5%20er%20der%20ikke%20mere%20gyrate%20til%20h%C3%B8jre%20og%20der%20har%20vi%20det%20hitte%20en%20overs%C3%A6tter!
so you can use the quite flexible Apple routines
[i]TEXT ENCODING SUB-ROUTINE
This sub-routine is used in conjunction with the encoding characters sub-routine to encode spaces and high-level ASCII characters (those above 127) in passed text strings. There are two parameters which control which characters to exempt from encoding.
The first parameter: encode_URL_A is a true or false value which indicates to the sub-routine whether to also encode most of the special characters reserved for use by URLs.
The second parameter: encode_URL_B is false, thereby exempting periods (.), colons(:), underscores (_), and hypens (-) from encoding
In the following example the encode_URL_A value is false thereby exempting the asterisk (*) character, which has a special meaning in URL’s, from the encoding process. Only spaces and high-level ASCII characters, like the copyright symbol are encoded.
[/i]
encode_text("*smith-wilson© report_23.txt", false, false)
--> "*smith-wilson%A9%20report_23.txt"
-- this sub-routine is used to encode text
on encode_text(this_text, encode_URL_A, encode_URL_B)
set the standard_characters to "abcdefghijklmnopqrstuvwxyz0123456789"
set the URL_A_chars to "$+!'/?;&@=#%><{}[]\"~`^\\|*"
set the URL_B_chars to ".-_:"
set the acceptable_characters to the standard_characters
if encode_URL_A is false then set the acceptable_characters to the acceptable_characters & the URL_A_chars
if encode_URL_B is false then set the acceptable_characters to the acceptable_characters & the URL_B_chars
set the encoded_text to ""
repeat with this_char in this_text
if this_char is in the acceptable_characters then
set the encoded_text to (the encoded_text & this_char)
else
set the encoded_text to (the encoded_text & encode_char(this_char)) as string
end if
end repeat
return the encoded_text
end encode_text
on encode_char(this_char)
set the ASCII_num to (the ASCII number this_char)
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
set x to item ((ASCII_num div 16) + 1) of the hex_list
set y to item ((ASCII_num mod 16) + 1) of the hex_list
return ("%" & x & y) as string
end encode_char