Aspbo

Från Rilpedia

Hoppa till: navigering, sök
Wikipedia_letter_w.pngTexten från svenska WikipediaWikipedialogo_12pt.gif
rpsv.header.diskuteraikon2.gif

I got fed up with looking up unicode characters, so I wrote an AppleScript for my favorite styled text editor Style to write them for me. Now, I can just type Japanese into a text edit window like this

小 泉 純 一 郎

select it, choose my script from the scripts menu, and it turns into

小 泉 純 一 郎 & #23567; & #27849; & #32020; & #19968; & #37070;

Which is what you can paste into the Wikipedia edit window. I'm using a Mac, so this is a mac only solution, but I thought I'd share it for those of you who can use it. Here's the script:

____ begin script _____


set theHTML to ""
tell application "Style"
set selText to selection of document 1 as Unicode text
set selStart to get offset of selection of document 1
set selEnd to get offset of end of selection of document 1
set dataLen to (selEnd - selStart)
end tell
set tempName to "unicode temp"
tell application "Finder"
if alias tempName exists then
move alias tempName to the trash
end if
end tell
set fileRef to open for access tempName with write permission
write selText to fileRef
set myRawData to read fileRef from 0 for dataLen
close access fileRef
tell application "Finder"
move alias tempName to the trash
end tell
set numChars to dataLen div 2
repeat with n from 1 to numChars
set theHTML to theHTML & "&#"
set a to get character (2 * n - 1) of myRawData
set b to get character (2 * n) of myRawData
set lVal to ((ASCII number b) + (256 * (ASCII number a)))
set theHTML to (theHTML & lVal as string) & "; "
end repeat
tell application "Style"
set selection of document 1 to ((selection of document 1) & " ( " & theHTML & " ) ")
end tell

____end script ____

compile this in ScriptEditor, and save it in the "Style Scripts folder in the same folder where the Style application lives. I have mine saved as "Append Unicoded HTML". Thereafter it will appear in Style's Scripts menu.

Style is available at merzwaren ($20 shareware). I have this running on Mac OS X 10.2.1 with Style version 1.9.2

Enjoy !

Olof
Personliga verktyg