Re: Length of string as UTF-8
Re: Length of string as UTF-8
- Subject: Re: Length of string as UTF-8
- From: Yvan KOENIG <email@hidden>
- Date: Sun, 6 Aug 2006 16:08:52 +0200
Le 6 août 2006 à 11:29, Tom Robinson a écrit :
Hi people,
Is there a way to get the length of a Unicode string as it would be
represented in UTF-8?
I have an AppleScript which uses Unicode strings, which I then
write to a file. I need to keep the files under 4096 bytes for
displaying on an iPod.
e.g.:
set a to "don’t" as Unicode text -- that's a right single curly quote
log length of a -- This returns 5, but underlying AS it's probably
10 (the quote being U2019)
log length of (a as «class utf8») -- This still returns 5, but I'd
like something similar to this which returns 7 (the quote being
UTF-8 e2 80 99)
Thoughts?
Hello
As far as I know, the length function returns the number of
characters in the "measured" text. It doesn't return a byte count.
At this time, I have only one idea: write the chunk of text in a text
file and grab the file's eof value.
Yvan KOENIG _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden