Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Need a help for javascript in photoshop

Community Beginner ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

How to solve the Chinese garbled problem when writing a script,
For example, get the Chinese file name of the file

TOPICS
Actions and scripting

Views

324

Likes

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

Participant , Jun 25, 2021 Jun 25, 2021
Try using these two depending on which direction you're going: Option a. uses activeDocument.name as @Kukurykus is suggestingOption b. uses the name of a file loaded from disk decodeURI(...) & encodeURI(...)URI = a Resource Identifier, google the U if you want to know and read up. decodeURI & encodeURI are functions that convert a string to a URI's or an URI's to a string. //a. if you want the name of the opened document: var ChineseFileName = activeDocument.name; //b. if you want the name of...

Likes

Translate

Translate
Adobe Community Professional ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

activeDocument.name

Likes

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
Adobe Community Professional ,
Jun 24, 2021 Jun 24, 2021

Copy link to clipboard

Copied

Where do you write the script?

The editor must support at least UTF-8 encoding and and use a byte order mark (BOM).

 

PS. How to address you, nameless you are ours.

Likes

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
Adobe Community Professional ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

LATEST

I saw more nameless users in that time, so that had(?) to be some forum bug.

Likes

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
Participant ,
Jun 25, 2021 Jun 25, 2021

Copy link to clipboard

Copied

Try using these two depending on which direction you're going:

 

 

Option a. uses activeDocument.name as @Kukurykus is suggesting

Option b. uses the name of a file loaded from disk

 

decodeURI(...) & encodeURI(...)

URI = a Resource Identifier, google the U if you want to know and read up. 😉

decodeURI & encodeURI are functions that convert a string to a URI's or an URI's to a string.

 

//a. if you want the name of the opened document:
var ChineseFileName = activeDocument.name;

//b. if you want the name of a file on disk somewhere:
var fileRef = "C:/hineseFileName.jpg";
var ChineseFileName  = new File( fileRef ) ;

//turns a garbled name into a readable name (if you can read hanzi, which I can't)
decodeURI(ChineseFileName.name);

//turns a readable name (the hanzi) into a garbled name (format that makes computer happy)
encodeURI(ChineseFileName.name);

 

Likes

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