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

How to make the script support Chinese, Japanese and other languages when getting ink.name?

Contributor ,
Nov 20, 2023 Nov 20, 2023

The illustrator script cannot support Chinese, Japanese and other languages when getting ink.name, and it displays garbled characters.

Seeking guidance and assistance from the community's experts. Thank you, everyone!

 

 

  var doc = app.activeDocument;
  var inkList = doc.inkList;
  var inkUsage = [];


  for (var i = 0; i < inkList.length; i++) {
    var ink = inkList[i];
      var inkName = ink.name;
      inkUsage.push(inkName);
      }

    alert(inkUsage.join("\n"));
    $.write(inkUsage.join("\n"));

 

 

 

error.jpg

TOPICS
Scripting
1.8K
Translate
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

Engaged , Jul 04, 2024 Jul 04, 2024
Translate
Adobe
Enthusiast ,
Nov 20, 2023 Nov 20, 2023

This may be useless, but try the string 

var inkName = decodeURIComponent(ink.name);
Translate
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
Contributor ,
Nov 21, 2023 Nov 21, 2023

@Sergey Osokin 

I have tried doing it myself, but I still got the same result which is garbled characters.

I suspect that ink.name does not support non-English language environments.

However, I still appreciate your response!

Translate
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 ,
Nov 21, 2023 Nov 21, 2023

Hi @Aprking, it might be worth posting a demo file showing example ink names. So people can look into it further.

- Mark

Translate
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
Contributor ,
Nov 21, 2023 Nov 21, 2023

@m1bThe information output by the above JSX script appears as garbled characters in versions of Illustrator running in Chinese, Japanese, and other non-English languages. Currently, I am not aware if the information output is abnormal in all other non-English language versions of Illustrator.

Translate
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
Enthusiast ,
Nov 21, 2023 Nov 21, 2023

I have checked the Cyrillic version of the interface. I confirm that inkList returns encoded names. I cannot yet determine which encoding is used.

 

[Ink Òðèàäíûé Ãîëóáîé],[Ink Òðèàäíûé Ïóðïóðíûé],[Ink Òðèàäíûé Æåëòûé],[Ink Òðèàäíûé ×åðíûé]

It should stand for

[Ink Триадный Голубой],[Ink Триадный Пурпурный],[Ink Триадный Желтый],[Ink Триадный Черный]

 

Translate
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
Contributor ,
Nov 21, 2023 Nov 21, 2023

Even when running this script in the English version of Illustrator to retrieve ink.name, if the Spot Color name is in Chinese, Japanese or any non-English language, it cannot display the true spot color name correctly. Instead, it shows as Global Color, Global Color1... Therefore, I have tried various encoding and decoding methods, but I still cannot obtain the correct names for CMYK and Spot Colors.

spotname.jpg

Translate
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
Enthusiast ,
Nov 21, 2023 Nov 21, 2023

I also confirm this problem in different AI versions.

Translate
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
Contributor ,
Nov 21, 2023 Nov 21, 2023

I would like to obtain information about the ink names currently used in the document. Besides 'ink.name,' I'm not sure if there are any other methods. Can you provide more insights?

Thank you for your reply!

Translate
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
Enthusiast ,
Nov 21, 2023 Nov 21, 2023

I was wondering what is stored in the XMP of the document data. And as we can see on the screenshot, blue and orange plates with non-English names are also not added to the xmpTPg:PlateNames property. Read the Adobe XMP Specification about xmpTPg:PlateNames: "An ordered array of plate names that are needed to print the document (including any in contained documents)".

 

I don't associate this with the scripted inkList attribute. But I find that the problem is broader than scripts

xmpdata.jpg

Translate
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
Enthusiast ,
Nov 22, 2023 Nov 22, 2023

And here are the unnamed Global Color swatches when you open the .ai file with a code editor

 

[/Separation/Custom#20Green/DeviceCMYK<</C0[0.0 0.0 0.0 0.0]/C1[0.77 0.01 0.85 0.0]/Domain[0 1]/FunctionType 2/N 1.0/Range[0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]>>]

[/Separation/Global#20Color/DeviceCMYK<</C0[0.0 0.0 0.0 0.0]/C1[1.0 0.01 0.0 0.17]/Domain[0 1]/FunctionType 2/N 1.0/Range[0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]>>]

[/Separation/Global#20Color#202/DeviceCMYK<</C0[0.0 0.0 0.0 0.0]/C1[0.06 0.32 1.0 0.04]/Domain[0 1]/FunctionType 2/N 1.0/Range[0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]>>]

 

And here are those swatch names in some Unicode encoding in DocumentCustomColors, which we also get in inkList

 

%%DocumentCustomColors: (Custom Green)
%%+ (Синий)
%%+ (オレンジ)

 

Translate
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
Contributor ,
Nov 22, 2023 Nov 22, 2023

My friend, you are truly dedicated, and I am extremely grateful for your assistance. I have considered using Global Colors and their corresponding Spot Colors in the Swatches panel to obtain the correct Spot Color names.

However, I have discovered that if Spot Colors are deleted or new ones are added during the process, the Global Color names will increment as Global Color i+1. This makes it impossible to establish a complete correspondence between Spot Colors and Global Colors. Furthermore, when iterating through the Spot Color names in the Swatches panel, they are not sorted by creation time but rather by the Spot Color's name, rendering this method ineffective.

Well, it seems that resolving this issue is indeed impossible. Nevertheless, I still appreciate your help, my friend.

Translate
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
Engaged ,
Jul 04, 2024 Jul 04, 2024
LATEST
Translate
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