Hi there.
Just a quick question:
I have a script that sets artwork to the currently playing song. But I can’t use “current track” because I use this in a thread in cocoa and if i use current track it might set the artwork to the wrong song. So I pass it the artist and the album name. But those might be Japanese characters, or, in that matter, non - roman characters. And if they are non-roman characters, the script will “crash”. So how can I add support for japanese strings, knowing that I don’t KNOW whether it’s japanese or roman characters.
thank you very much,
oddy
Would you post the script that is crashing?
sure - where’s my head 
set pathToImage to ":private:tmp:myfile.tiff"
tell application "Image Events"
launch
set imageFile to (open pathToImage)
save imageFile as PICT
end tell
tell application "iTunes"
set artiststr to "鬼æŸã¡ã²ã‚"
set albumstr to "インソムニア"
set currentArtwork to (read file pathToImage from 513 as artwork)
repeat with mySong in ((tracks of library playlist 1) whose album is albumstr)
if ((artist of mySong) as string) is equal to artiststr then
if not (exists artworks of mySong) then
set data of artwork 1 of mySong to currentArtwork
end if
end if
end repeat
end tell
everything must remain the same as is, works like a charm. the only things that need tweeking is "set artiststr to “…” " and “set albumstr…”. This is a version where it was passed japanese characters. The same script is used when passed roman characters.
thanks!
Took me a few minutes to track down the right thread, but I found it. 
Try using these instead:
set artiststr to «data utxt9B3C675F30613072308D» as Unicode text
set albumstr to «data utxt30A430F330BD30E030CB30A2» as Unicode text
The problem here is that “AppleScript compiles scripts using the system’s primary encoding.” You read more in this thread by kai: Using Unicode-only characters in script strings (Also, kai’s post contains a script that you can use to get the Unicode codepoints for characters, if you need to change those your text later.)
Edit: P.S. kai, that’s a great thread and script! 
the thing is - i don’t know what characters are going to be there. and if they happen to be japanese, i don’t know which japanese characters they are… so I can’t use the script you wrote in your previous post (thanks, by the way!!)…
Edit: I don’t understand how you’re calling this from Cocoa.
Edit: Side note: You can check the album and artist at the same time:
tracks of library playlist 1 whose album is albumstr and artist is artiststr
repeat with mySong in result
if not (exists artworks of mySong) then
set data of artwork 1 of mySong to currentArtwork
end if
end repeat
it doesn’t matter how i use this from cocoa.
all that matters is that the artiststr and albumstr are either roman or non-roman characters. Now is there a way to create unicode of japanese characters?
ok, let’s try it differently. let’s use the database ID.
but when I do this (for experimental use):
tell application "iTunes"
return (album of (track whose database ID is 1385))
end tell
it gives me this error:
Yes, a track with a database ID 1385 exists… what am i doing wrong?
thank you very much,
oddy
EDIT:
Ok, when I do this, it won’t work:
tell application "iTunes"
return (data of artwork 1) of ((tracks of library playlist 1) whose database ID is 1443)
end tell
but when i do this:
tell application "iTunes"
return name of ((tracks of library playlist 1) whose database ID is 1443)
end tell
it works like a charm. But i really need that coverart data…
thx