Converting Mac Roman and/or UTF 16 to UTF 8?
Converting Mac Roman and/or UTF 16 to UTF 8?
- Subject: Converting Mac Roman and/or UTF 16 to UTF 8?
- From: Richard Rönnbäck <email@hidden>
- Date: Wed, 14 Sep 2005 10:05:24 +0200
Is there a way to convert a text file with one encoding, to another
encoding, using standard AppleScript or shell commands only, and without
relying on external applications?
The background is this:
I am trying to prepare XML-data for Illustrator 12 variable graphics. The
data is exported from FileMaker 7 by using a calculation field and then
exporting that field for all records to a tab separated text file, using
FM's built-in feature.
After the export the data must be "padded" with a header part and a footer
part.
The problem is that Illustrator is very picky and accepts perfect UTF-8
encoded XML only, which is not an option when exporting from FM.
That means that all attempts I have tried to merge the header, exported
data, and footer using Standard Additions Read and write commands have
failed, because although the header part is correct UTF-8) the FM exported
part in the middle has the wrong encoding.
I know that the encoding is the problem, because TextWrangler informs me
about encodings etc.
It seems I can convert encodings by simply cutting and pasting into a UTF 8
"template" using TextEdit for example, but I would prefer doing it in a
faceless mode and, as I want it as smooth as possible for the end users
So, that's the problem. If anyone has a good suggestion for a solution I
would be very grateful
/ Richard
PS
I'm not sure if the AppleScript code is of any use, as you have to have the
FM part and the Illustrator file to verify the file, but anyway, below it
is:
set myHeader to "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20001102//EN\"
\"http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd\" [
<!ENTITY ns_graphs \"http://ns.adobe.com/Graphs/1.0/\">
<!ENTITY ns_vars \"http://ns.adobe.com/Variables/1.0/\">
<!ENTITY ns_imrep \"http://ns.adobe.com/ImageReplacement/1.0/\">
<!ENTITY ns_custom \"http://ns.adobe.com/GenericCustomNamespace/1.0/\">
<!ENTITY ns_flows \"http://ns.adobe.com/Flows/1.0/\">
<!ENTITY ns_extend \"http://ns.adobe.com/Extensibility/1.0/\">
]>
<svg>
<variableSets xmlns=\"&ns_vars;\">
<variableSet varSetName=\"binding1\" locked=\"none\">
<variables>
<variable varName=\"Fondkurser\" category=\"&ns_graphs;\"
trait=\"graphdata\"></variable>
</variables>
<v:sampleDataSets xmlns=\"&ns_custom;\" xmlns:v=\"&ns_vars;\">"
set myFooter to "</v:sampleDataSets>
</variableSet>
</variableSets>
</svg>"
set myFile to (open for access (choose file with prompt "Please choose the
exported FileMaker file") with write permission)
set myData to (read myFile)
close access myFile
set myFile to (open for access (choose file name with prompt "Please choose
a name and location for the new file") with write permission)
write myHeader & myData & myFooter to myFile
close access myFile
return myFile
------ Slut på vidarebefordrat meddelande
_______________________________________________
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