convert to UTF-8
Mark Schonewille
m.schonewille at economy-x-talk.com
Mon Jun 25 07:13:59 EDT 2007
Mark,
You are right that uniencode converts all characters to double-byte,
while UTF8 does so only where necessary. Using uniencode() only work
with most, if not with all, unicode-compatible text editors though,
until you start editing the text in the text editor and find out that
the text includes superfluous NULLs.
I tested the following scripts:
on saveUC
put binaryEncode("H*","EFBBBF") into myBOM
put myBOM & uniencode("hello world","utf8") into url "binfile:~/
desktop/text.txt"
end saveUC
on saveUC2
put binaryEncode("H*","EFBBBF") into myBOM
put myBOM & unidecode(uniencode("hello world"),"utf8") into url
"binfile:~/desktop/text.txt"
end saveUC2
and the second script saves a clean UTF8 file which is automatically
recognised as UTF8 by Apple's TextEdit. The first script works too,
but TextEdit doesn't remove the superfluous NULLs when opening the file.
Torbjörn, your solution is correct and you are not doing anything
stupid :-)
Best regards,
Mark Schonewille
--
Economy-x-Talk Consulting and Software Engineering
http://economy-x-talk.com
http;//www.salery.com
Quickly extract data from your HyperCard stacks with DIFfersifier.
http://differsifier.economy-x-talk.com
Op 25-jun-2007, om 12:16 heeft Mark Smith het volgende geschreven:
> Mark, is that really so? I thought the uniEncode function will
> convert all single-byte characters to double-byte characters - not
> UTF8. Is that not what happens?
>
> Best,
>
> Mark
>
> On 25 Jun 2007, at 11:11, Mark Schonewille wrote:
>
>> If the original string is plain text, you can use uniEncode
>> (theString)
More information about the use-livecode
mailing list