CYRTextView icon indicating copy to clipboard operation
CYRTextView copied to clipboard

Setting HTML entities such as ♣ show up as emoticons

Open nnhubbard opened this issue 12 years ago • 9 comments

For some reason, when setting a text string that contains an HTML entity, it renders that as an emoticon. Such as using ♣ will show the clubs icon.

It really shouldn't do this, as a plain UITextView with an attributed string doesn't do this. So somewhere in CYRTextView is the issue I would assume.

nnhubbard avatar Feb 17 '14 22:02 nnhubbard

Hi Nic!

We don't do anything special with emoticons in CYRTextView. I ran a test with a vanilla UITextView and am seeing the same issue where the spade is converted into an emoticon when setting just the text or attributedText property. I'm not really sure how do solve this issue right now but will investigate this coming weekend.

If you find out anything please let me know :).

Illya

illyabusigin avatar Feb 18 '14 00:02 illyabusigin

Hmm, I also had done a test with just a plain UITextView and I didn't see the issue. Can you post the code that produced it? One of the Apple devs would be interested in the dev forums.

nnhubbard avatar Feb 18 '14 00:02 nnhubbard

See below:

 UITextView *textView = [[UITextView alloc] initWithFrame:self.view.frame];

// Test #1
textView.text = @"Emoticon Test: ♣ \u2663"; // \u2663 is the unicode character for ♣, displays an emoticon

// Test #2
textView.attributedText = [[NSAttributedString alloc] initWithString:@"Emoticon Test 2: ♣ \u2663"]; // displays an emoticon

// Test #3
textView.attributedText = [[NSAttributedString alloc] initWithString:@"Emoticon Test 2: &clubs"]; // displays &clubs

[self.view addSubview:textView];

illyabusigin avatar Feb 18 '14 01:02 illyabusigin

Well, I didn't have issues with unicode characters, just ♣ (and many others) showing an emoticon. So, not sure if this is a CYRTextView bug, or a TextKit/UIKit bug.

nnhubbard avatar Feb 18 '14 05:02 nnhubbard

Perhaps "♣" should be escaped to avoid conversion to emoticon?

LeoNatan avatar Feb 21 '14 19:02 LeoNatan

Do you mean escaping HTML entities?

nnhubbard avatar Feb 21 '14 20:02 nnhubbard

Yeah, if "& clubs;" shows as an emoticon (haha, Github also shows it so), "& amp;clubs;" will show correctly.

LeoNatan avatar Feb 21 '14 20:02 LeoNatan

Yeah, but you can't expect a user to do this.

nnhubbard avatar Feb 28 '14 21:02 nnhubbard

Perhaps it would be best to have additional methods for setting and getting escaped text.

  • (void)setText:(NSString*)text escape:(BOOL)escape;
  • (void)setAttributedText:(NSAttributedString*)attributedText escape:(BOOL)escape;
  • (NSString*)escapedText;
  • (NSAttributedString*)escapedAttributedText;

LeoNatan avatar Mar 01 '14 03:03 LeoNatan