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

Tring to remove first character from a string if it's a particular emoji

Engaged ,
Feb 16, 2024 Feb 16, 2024

Copy link to clipboard

Copied

So I'm trying to remove the first character from a string if that character is a particular emoji. So far I have the code below which seems to work apart from the line 'name = name:sub(2)', which seems to just produce junk. Sorry for the screen grab, this page doesn't like emojis

 

Any thoughts, anyone? 

 

Screenshot 2024-02-16 at 11.16.19.png

 

 

 

 

TOPICS
macOS , SDK

Views

148

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
LEGEND ,
Feb 16, 2024 Feb 16, 2024

Copy link to clipboard

Copied

[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]

 

How LR handles Unicode strings in Lua isn't documented anywhere I know of (except on this forum).

 

Lua strings are sequences of 8-bit bytes, and Lua itself doesn't understand any Unicode encodings. If you write the following in a .lua source file and save the file encoded as UTF-8:

johnrellis_0-1708105492642.png

the source file contains four bytes between the open and close quotes. (The Unicode Red Textbook character is encoded in UTF-8 as four bytes.) Lua reads it as a four-byte string "\240\159\147\149". For example:

 

johnrellis_1-1708105896471.png

 

Lua doesn't provide any built-in operations for manipulating strings as sequences of Unicode characters, though there are open-source modules that provide UTF-8 operations on Lua strings.

 

LR generally treats Lua strings as containing UTF-8 encodings, so when LR displays a Lua string in its UI controls, it will interpret the string as UTF-8. (The screenshot above is from my debugging toolkit, which uses LrView controls.)

 

Finally, to remove the Unicode Red Texbook character from the beginning of a string, you could write:

johnrellis_2-1708106362553.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
LEGEND ,
Feb 16, 2024 Feb 16, 2024

Copy link to clipboard

Copied

And I just remembered my more concise post on this topic from 2010:

https://community.adobe.com/t5/lightroom-classic-discussions/how-the-sdk-handles-unicode/m-p/3072295

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
Engaged ,
Feb 17, 2024 Feb 17, 2024

Copy link to clipboard

Copied

LATEST

That did the job. Many thanks, John.

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