illyabusigin / CYRTextView

CYRTextView is a UITextView subclass that implements a variety of features that are relevant to a syntax or code text view.
MIT License
535 stars 71 forks source link

Setting HTML entities such as ♣ show up as emoticons #10

Open nnhubbard opened 10 years ago

nnhubbard commented 10 years ago

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.

illyabusigin commented 10 years ago

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

nnhubbard commented 10 years ago

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.

illyabusigin commented 10 years ago

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];
nnhubbard commented 10 years ago

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.

LeoNatan commented 10 years ago

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

nnhubbard commented 10 years ago

Do you mean escaping HTML entities?

LeoNatan commented 10 years ago

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

nnhubbard commented 10 years ago

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

LeoNatan commented 10 years ago

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