2

I want to display the text layer contents of my psd on a txt file (csv format). The problem is if the the text is Arabic or Thai the text displayed is "????"

This is how i retrive the texts from the psd layers:

function TextChecker() {
  LayerContent = [];
  var iLayer =       app.activeDocument.activeLayer.textItem;
  var layerContent = iLayer.contents;

 //If statement here...

 //If text layer found push layer content into   
 //an array (LayerContent) then return
 //LayerContent

return LayerContent;
}

Then I push it on a array After that i write the texts like this:

 var Info = TextChecker();
 Name = app.activeDocument.name.replace(/\.[^\.]+$/, ' ');
 var file = new file(docRef.path + "/" + Name + ".csv");
 for (var a In Info) {
   //alert(Info[a]);
   file.writeln(Info[a][0]);
 }

I tried to display first the text before it will be writen in the text file and it displays the text properly (in arabic / thai font) but after its written the text is different.

Reasearch:

1. Found out about file.encoding, tried everything. Only UTF-8 is makes the text readable (only in Japanese katakana)

2. Instead of '.csv' file. I used '.txt' as file extension when creating a new file. And used 'file.encoding = "UTF-8"' this time the texts are displayed properly.

Question: is there a way to output arabic/thai text properly on a csv file???

Maguzu
  • 433
  • 3
  • 7
  • 14
  • You'll have to make sure all the things are utf8 encoded. Also note that a `csv` file is **not** an Excel file, it's a plain text "Comma-Separated Values" file, a data format that can be read by million of applications. – Mike 'Pomax' Kamermans Nov 24 '16 at 06:19
  • Tried adding 'file.encoding = "UTF-8"; after 'file.open' but it displays a different text. – Maguzu Nov 24 '16 at 06:34
  • Does keyboard setting affect the text output? – Maguzu Nov 28 '16 at 14:47
  • seems unlikely. However, I'm amazed your code even does anything at all: `TextChecker` does not return any values, so `var Info = TextChecker();` should result in `Info` being undefined. Without any information on which version of PS you're using, I'm going to assume "latest", in which case you're using ExtendScript 3.8, and you need to read the "known issues" in http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/scripting/pdfs/extendscript_toolkit_readme.pdf, particularly point 3.4 about UTF files. – Mike 'Pomax' Kamermans Nov 29 '16 at 16:11
  • Also note that this is a truly ancient version of JavaScript btw (it's an ES3 derivative, so circa 1998. That said, even back in 1998 `for (.. in ..)` was a terrible idea without testing for `hasOwnProperty` as the very first thing in the loop - see http://stackoverflow.com/questions/12735778/for-in-and-hasownproperty for a discussion. – Mike 'Pomax' Kamermans Nov 29 '16 at 16:12
  • @Mike 'Pomax' Kamermans: My photoshop version is CC. – Maguzu Dec 05 '16 at 16:50
  • Possible duplicate of [Output Arabic/Thai text in Excel file using Photoshop JavaScript](http://stackoverflow.com/questions/39314554/output-arabic-thai-text-in-excel-file-using-photoshop-javascript) – Mr Mystery Guest Jan 06 '17 at 13:42

0 Answers0