Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: Write a string to text with .write

$
0
0

> So i should always specify the encoding then?

 

It actually depends on what further purpose you use the exported "plain text" file for. Not all plain text editors can read UTF-8 (TextWrangler, my editor of choice on the Mac can, but TextPad, the nearest Windows equivalent, cannot).

Some text editors *expect* a UTF-8 BOM code at the start of the file; others do not.

See Kasyan's struggle with uncommon characters systems in this thread: http://forums.adobe.com/thread/1141456?tstart=60

 

("Uncommon" only from the narrow point if view from both Microsoft and Apple -- there is nothing uncommon about Uwe, having German accented characters in his paragraph style names, and Kasyan's Cyrillic characters in same.)

 

Apart from always using UTF-8 (either with or without BOM), you don't have many *realistic* options. Before writing your text file, you could scan your gathered text string for any character *not* in MacRoman Encoding (this is just a list of 256 Unicodes) and replace these with a question mark. But 1. Kasyan's Cyrillic text, for example, would then be replaced in its entirety with ????'s; and, 2. you cannot properly read a MacRoman encoded text file on a Windows machine.

The same argument goes against converting to a Windows Encoding ("a" -- there are too many of them to list here).

 

Actually, the safest way would be to throw away everything not 7-bit ASCII. But then you'd still have an issue with line endings! Mac, Unix, Windows ...

 

You could try to stuff all of the above options into a dialog box and let the user decide :-/


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>