Force string to be UTF-8?
Force string to be UTF-8?
- Subject: Force string to be UTF-8?
- From: Tom Robinson <email@hidden>
- Date: Tue, 11 Nov 2003 08:00:27 +1300
Hi folks,
I've ended up with some data in a string variable which is really UTF-8: i.e. there's strings of 1, 2, and 3 bytes representing single Unicode characters. I need a way to force AppleScript to interpret this as a UTF-8 string. i.e., something like:
set class of a to <<class utf8>> -- which of course you can't do, class is read only
This long method works:
tell application "FileMaker Pro" to set a to cell 1 of current record
log a -- UTF-8 sequences inside a string variable
write a to file ((path to desktop as text) & "junk.txt") -- Write it as a string
set b to read file ((path to desktop as text) & "junk.txt") as <<class utf8>> -- Read it back as UTF-8
log b -- Desired result: UTF-8 string
But I need to run this over thousands of records, so want something faster.
This has all come about because FileMaker (still) doesn't handle UTF-8 natively, but it does handle high ASCII fine--so I can store the UTF-8 sequences in the database, it's just a matter of extracting them again... unfortunately FM doesn't support adding 'as <<class utf8>>' to the first statement above.
Thanks.
--
Women DO come with instructions. Just ask them!
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.