Re: Encoding text file to write XML
Re: Encoding text file to write XML
- Subject: Re: Encoding text file to write XML
- From: Sander Tekelenburg <email@hidden>
- Date: Sat, 31 Oct 2009 17:13:12 +0100
At 15:14 +0000 UTC, on 2009-10-31, Hagimeno wrote:
> Hi all,
We need to generate a XML file with data that contains private
>chars like >.
What's the best method to write XML file using AppleScript
>(without to use 3rd parts scripting additions) and automatically convert
>reserver chars?
Something about your message's encoding seems messed up, so I'm not sure I
see the caracters you intended to be seen. Might be 'just' broken line
endings though.
If you're talking about the ">" character -- this has nothing to do with
encoding. It's a reserved character in XML, so you'll need to escape it if
you want to use it as a 'regular' character. How to do that is specific to
XML, nothing to do with AppleScript -- look it up in the XML spec.
If I misunderstood, and you really are talking about encoding and
transliteration:
One doesn't just "convert", but converts "from, to". So your script needs to
know the input text's character repertoire, and transliterate that to an
appropriate character repertoire for output -- that is, assuming that the
input's character repertoire isn't appropriate for output in the first
place...
Vanilla AS can read and write text as MacRoman, utf-8 and utf-16 (and
latin-1, I think -- not sure). If the character repertoire of the input text
is something else, you'll probably need to first transliterate it to one of
those, which is possible with cli tools (installed by default), through do
shell script.
Without knowing details of what you need to be able to do with the XML file,
utf-8 is probably a good choice to write to:
write to myXMLfile as «class utf8»
--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden