Skip to content

ST1018: don't flag emojis containing U+FE0F,U+200D - #1456

Closed
1sixth wants to merge 1 commit into
dominikh:masterfrom
1sixth:fix-ST1018
Closed

1sixth wants to merge 1 commit into
dominikh:masterfrom
1sixth:fix-ST1018

Conversation

@1sixth

@1sixth 1sixth commented Oct 19, 2023

Copy link
Copy Markdown

Background: #1113

staticcheck/v0.4.6 reports

string literal contains the Unicode format character U+200D, consider using the '\u200d' escape sequence instead (ST1018)

for emojis containing the sequence U+FE0F,U+200D1. The reason is that U+FE0F is not in unicode.S. This PR adds a special check for it.

Example Program
package main

import (
	"fmt"
	"unicode"
)

func main() {
	// https://en.wikipedia.org/wiki/Zero-width_joiner#Examples
	emojis := [...]string{
		"👨‍👩‍👦",
		"🏳️‍🌈",
	}

	for _, emoji := range emojis {
		fmt.Println(emoji)
		for _, e := range emoji {
			fmt.Printf("%+12q unicode.S: %v\n", e, unicode.Is(unicode.S, e))
		}
	}
}

Footnotes

  1. There are lots of them, see https://www.unicode.org/Public/emoji/15.1/emoji-zwj-sequences.txt ↩

Previous check didn't exclude this case.
@dominikh dominikh closed this in c6439b7 Nov 6, 2023
@dominikh

dominikh commented Nov 6, 2023

Copy link
Copy Markdown
Owner

Thank you, but I went with a more exhaustive approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants