SuperCard Shell Essentials

 

Macroman and utf8

Page history last edited by DCS 3 yrs ago

Macroman and Utf8

 

Utf8 impacts Mac characters with ascii values larger than 127.

Text manipulation

In the example below characters are returned as passed.

 

on mouseup
--Synopsis: pass a bunch of chars and reverse the order
put " ¡™£¢∞§¶•ªº–≠œ∑鮆¥¨ˆøπ“‘åß∂ƒ©˙∆˚¬…æΩ≈ç√∫˜µ≤" into str
put "≥÷⁄€‹›fifl‡°·‚—±Œ„´‰ˇÁ¨ˆØ∏”’ÅÍÎÏ˝ÓÔÒÚÆ¸˛Ç◊ı˜Â¯˘¿" after str
--load a variable with character ascii values > 127
put "echo `[[str]]` | " into cmd
--inject str
put "perl -pe 's/(.){1}/$1n/' | " after cmd
--add a linefeed after each character
put "rev | " after cmd
--reverse line order
put "tr -d `n` ; " after cmd
--delete the linefeeds
put merge(cmd) into cmd
--merge command syntax
get shell(cmd)
--execute
alert sheet "Original/reverse order:" explain str & cr & cr & it
--display results
end mouseup

Top

System operations

In the example below, utf8 encoding/decoding appears necessary.

 

on mouseup
--synopsis: make a new folder with a registered trademark symbol in the name
--          in the users home folder
--          then list home folder
put "`" into bq
--comand expansion metacharacter into a variable
put "cd ~/ ; " into cmd
--set working directory to users home folder
put "pwd ; " after cmd
--add users home folder to return
put "mkdir [[bq]]iconv -f macroman -t utf8 <<< `0test®`[[bq]] ; " after cmd
--make a new folder named '0test®' in home folder using 'mkdir'
--'iconv' converts the string '0test®' from macroman to utf8
--and the result is used as name of the new folder
--unencoded, 'mkdir "0test®" throws an 'invalid argument' error to the console.
put "_list=[[bq]]ls -F ~/ [[bq]] ; " after cmd
--list contents of home folder
put "_dir=[[bq]] grep -E '^0' <<< `$_list` [[bq]] ; " after cmd
--strip dir list to test folder and set variable
put "echo utf8: `$_dir` ; "after cmd
--display as utf8
put "echo macroman: [[bq]] iconv -f utf8-mac -t macroman <<< `$_dir` [[bq]] ; "after cmd
--convert and display as Macroman
put merge(cmd) into cmd
--merge command syntax
get shell(cmd)
--execute command syntax
ask list it
--display result
end mouseup

Top

Comments (0)

You don't have permission to comment on this page.