Is it possible to replace non-ascii characters in a string, or at least remove them?
Thanks,
gecko
Is it possible to replace non-ascii characters in a string, or at least remove them?
Thanks,
gecko
Hi,
is this sufficient?
set a to "123ºªÆ’ ΩabcÅ“@∆º!$%&"
do shell script "echo " & quoted form of a & " | tr -cd '[:print:]'"
--> 123abc@!$%&
I don’t know anything about UNIX, but is there a code snippet to convert just the smart/curly quotes and replace them with the foot or inch marks. - If not I will use this script above to just remove them, which does work well.
Thanks,
Jeff
Hello,
the AppleScript way:
on substitute(s, r, t)
set s to s as list
set r to r as list
set t to t as text
set tid to AppleScript's text item delimiters
repeat with i from 1 to count s
set AppleScript's text item delimiters to s's item i
set t to t's text items
set AppleScript's text item delimiters to r's item i
set t to t as text
end repeat
set AppleScript's text item delimiters to tid
return t
end substitute
set myText to "I'd like to surround one of the fields with straight quotes rather than smart quotes. I couldn't see anything in the "online help" about this.) "
set myText to substitute({""", """, "˜", "'"}, {"\"", "\"", "'", "'"}, myText)
or…
set myText to "I'd like to surround one of the fields with straight quotes rather than smart quotes. I couldn't see anything in the "online help" about this.) "
do shell script "awk '{gsub(/("|")/,\"\\042\"); gsub(/(˜|')/,\"\\047\"); print}' <<< " & quoted form of myText
or if you’re dealing with a file…
set p2file to "/Posix/path/to/myFile.txt"
do shell script "awk '{gsub(/("|")/,\"\\042\"); gsub(/(˜|')/,\"\\047\"); print}' < " & quoted form of p2file
I owe you one! You even gave me option! Many thanks.
-Jeff
I tried these two codes samples to delete invisible upside down ? character but i get:
→ error “sh: -c: line 0: unexpected EOF while looking for matching `‘’
sh: -c: line 1: syntax error: unexpected end of file” number 2
Did you consider the second single quote right before the ending double quote?