• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Charset of Textitem

Explorer ,
Jul 01, 2018 Jul 01, 2018

Copy link to clipboard

Copied

Hi,

We have a PHP and MYSQL system which generates a JSX file for design.

It pulls one value out of the database and via php to the jsx file.

We have an issue with some characters which are set in the UTF8 charset, which are correctly displayed in the database and in PHP and HTML.

But when set in photoshop code, it causes issues and displays them incorrectly.

For example

activeDocument.activeLayer.textItem.contents="""' . $rs_item['slogan_name'] . '"""; 

Du ser mig kun for det tøj jeg har på

This displays correctly in php, mysql etc, but when set in photoshop it displays to:

Du ser mig kun for det tøj jeg har på

Is there a way to set a charset for a value for photoshop?

I tried

activeDocument.activeLayer.textItem.encoding = "UTF8";

but i dont think there is such a value for textitem?

Thanks

TOPICS
Actions and scripting

Views

3.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jul 20, 2018 Jul 20, 2018

You here gave an example of your PHP script.

if($_SESSION['admin_name']!=="Admin") { 

// CLOSE THE TEMPLATE PSD AND OPEN THE ACTUAL DESIGN IN PSD 

$design_code .= ' 

 

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);   

var fileRef = "' . "/z/DESIGN_SERVER/" . $savefilename . ".psd" . '";   

app.open( new File( fileRef ) );  

'; 

} else { 

// CLOSE THE TEMPLATE PSD AND OPEN THE ACTUAL DESIGN PDF 

$design_code .= ' 

 

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);   

var fileRef =

...

Votes

Translate

Translate
Adobe
People's Champ ,
Jul 01, 2018 Jul 01, 2018

Copy link to clipboard

Copied

I do not understand.
In Photoshop, your code gives this text in the layer
Untitled-2.png
Show the real code that is executed in Photoshop. (jsx file)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

Hi, no sorry that is PHP code. That is selecting a php $ value. see original post for the 2 values

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 02, 2018 Jul 02, 2018

Copy link to clipboard

Copied

Photoshop does not execute PHP scripts as far as I know.

How do you make a photoshop perform its native scripting code. That's what interests me.

Most likely there is an encoding error

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

Hi,

We have a PHP file which generates lots of Photoshop lines of code and ends up with a full script.

It uses the php value $design_code .= '

And complies set jsx files up to 100-200 files long to design many features based on customers requirements.

So the PHP compiles the JSX code and executes it.

We have been working on it for several weeks and it has been working fantastically.

My question is purely about charsets and why when the script puts the contents in, vs copy and paste why it displays different.

Our processing is irrelevant to the question.

I am surprised that no one else is using PHP to compile JSX scripts.

Forget the $value, see the contents i wrote as an example.

Is there no charset setting in photoshop for contents?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

Here is an example of one piece of our script in php

if($_SESSION['admin_name']!=="Admin") {

// CLOSE THE TEMPLATE PSD AND OPEN THE ACTUAL DESIGN IN PSD

$design_code .= '

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

var fileRef = "' . "/z/DESIGN_SERVER/" . $savefilename . ".psd" . '"; 

app.open( new File( fileRef ) );

';

} else {

// CLOSE THE TEMPLATE PSD AND OPEN THE ACTUAL DESIGN PDF

$design_code .= '

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 

var fileRef = "' . "/z/DESIGN_SERVER/" . $savefilename . ".pdf" . '"; 

app.open( new File( fileRef ) );

';

}

You will see there is an IF THEN ELSE php statement which looks to see if the session admin_name = Admin

If it doesit will add JSX photoshop script lines to the $design_code value.

In this instance it is basically stating if the session value is Admin open the psd, whereas if it isnt admin, open the pdf version.

And so on, at the end of the PHP code we end up with a complied jsx file which is executed from the $design_code variable.

So for example when you are seeing the ' . this is simply coming out of the variable $design_code and sourcing the parameter in PHP in this case a value $saveflename which has been declared earlier in php code.

Regarding my question we have noticed differences between us setting text via .contents vs pasting in photoshop hence we were wondering if there was some sort of a charset mismatch in code vs pasting directly in to photoshop.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 04, 2018 Jul 04, 2018

Copy link to clipboard

Copied

Most likely, Photoshop does not understand the encoding of your code or the file that you send to it.

A simple example is two jsx files without BOM (Byte Order Mark) for UTF8.

alert("Du ser mig kun for det tøj jeg har på")

script_ok.jsx - Google Drive

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

// 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

alert("Du ser mig kun for det tøj jeg har på")

script_bad.jsx - Google Drive

In a short file, Photoshop correctly defines the encoding of UTF8. But in the second, where the first text is a simple text, the photoshop defines it as a system encoding such as CP1252 or similar.

Accordingly, the first file at execution gives

ok.png

A long file, with the same key code, gives something like this

bad.png

I do not know PHP at all, but I'll try to advise you to insert such a code

$ design_code. = '\xEF\xBB\xBF

// here comes your old code

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2018 Jul 04, 2018

Copy link to clipboard

Copied

r-bin  wrote

… A long file, with the same key code, gives something like this

bad.png

…

Hi r-bin ,

I cannot see this problem with PhotoShop CC 2018 v 19.1.5 on Windows 10 (1803).

What's your version? On what OS?

Thanks,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 04, 2018 Jul 04, 2018

Copy link to clipboard

Copied

Did you download and run the script_bad.jsx script or created it yourself via copy-paste? Works with an error in CC2018.1.4 and in CS6. All on Windows 7 x64 and x86.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2018 Jul 04, 2018

Copy link to clipboard

Copied

Hi,

I copy-pasted your code and ran it from the ESTK. No error.

Saved the pasted code and ran it from PhotoShop and also InDesign. No error.

Downloaded your script_bad.jsx, opened it in the ESTK and ran it. No error.

Well, now that you answered:

Downloaded your script_bad.jsx, did not open and did not save it in the ESTK.

Ran it from PhotoShop, ran it from InDesign:

Now I can see the error.

Regards,

Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

We are also having issues with hyphens ' putting ’ so it is a charset issues, but we have the correct charsets set on database connections, html and php page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2018 Jul 05, 2018

Copy link to clipboard

Copied

This one doesnt work notice the character is

’

activeDocument.activeLayer.textItem.contents="It’s";

but this does work

activeDocument.activeLayer.textItem.contents="It's";

note the character is

'

We have done a simple str_replace in php which will replace the first example for second.

But copy and pasting works fine for the first example, but doesnt in script and shows:

’

Also reference similar issues post

Inserting an apostrophe (char code '==39)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 06, 2018 Jul 06, 2018

Copy link to clipboard

Copied

Untitled-2.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 06, 2018 Jul 06, 2018

Copy link to clipboard

Copied

I tried that but it made no difference. I am on CS6

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 06, 2018 Jul 06, 2018

Copy link to clipboard

Copied

web2000

I tried that but it made no difference. I am on CS6

But it works in CS6.

activeDocument.activeLayer.textItem.contents="It’'s";  

Untitled-2.png

Show your full code.

Or specify what it does not work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 06, 2018 Jul 06, 2018

Copy link to clipboard

Copied

Ok it seems something else in our code is causing this. And end file is about 150-200 lines long, when we run just part of the code its fine, but with all the code it happens, so there must be something in the code causing it. Will do some more testing and come back thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 06, 2018 Jul 06, 2018

Copy link to clipboard

Copied

Have you tried to insert the UTF8 BOM marker at the beginning of your code ($design_code) as I suggested?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 15, 2018 Jul 15, 2018

Copy link to clipboard

Copied

Hi sorry didnt see this reply. Yes i added the UTF8 BOM marker at the start of the JSX file but it didnt work, see below.

I am still having issues with several characters another one is this one • showing as •

  1. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  2. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  3. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  4. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  5. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  6. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  7. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  8. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  9. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  10. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  11. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  12. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  13. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  14. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  15. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  16. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  17. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  18. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  19. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  20. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  21. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  22. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  23. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  24. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  25. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  26. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  27. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  28. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  29. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  30. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111
  31. // 111111111111111111111111111111111111111111111111111111111111111111111111111111111111

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 15, 2018 Jul 15, 2018

Copy link to clipboard

Copied

I did not understand what you wrote above.

Well, I do not know.

You, like, wrote that with a short code you are all right.
Then try at the very beginning of your sample long code to paste something like

var dummy_utf8 = "Du ser mig kun for det tøj jeg har på";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 19, 2018 Jul 19, 2018

Copy link to clipboard

Copied

Hi can you confirm the correct code to add please for UTF8 BOM marker as  those // 1111 is what you sent?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 19, 2018 Jul 19, 2018

Copy link to clipboard

Copied

I do not understand you at all. UTF8 BOM is three characters, a string of three bytes,

"\xEF\xBB\xBF"

or

String.fromCharCode (0xEF, 0xBB, 0xBF).

Try to google this question.

for example utf 8 - Encoding a string as UTF-8 with BOM in PHP - Stack Overflow

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

Hi,

Php is correctly formatting the text.

I have checked JSX files and its labelled correctly.

for example:

activeDocument.activeLayer.textItem.contents="""Tiocfiadh ár lá""";

So this JSX file has the above, which means PHP has correctly saved the correct text in the JSX file.

But when the JSX file is exceuted, it then shows

Tiocfiadh ár lá

in photoshop, so its something in photoshop charset causing it vs php.

Regarding the 111 code, you posted this back on

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

Put here a link to your "allegedly" correct jsx file. I'll see if it has UTF8 BOM

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

Will send as PM.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

web2000

Will send as PM.

You sent a copy-pasted text of the script where there are UTF-8 characters.

I do not need the text of the script. I need a specific jsx file, which is generated by your PHP script, and which you send the photoshop on for execution. I need a link to your file, not the text itself in this file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines