Display Emoji icons in Mac app - macos

I want the user to have easy access to Emoji icons in a small chat I am making for the company I'm working at.
Therefore, I want to make a panel which shows the available Emoji icons. To do this, I am using an NSCollectionView. Now, I need to pass a string which is shown in an NSTextField. This string must contain one Emoji icon.
I can't figure out how to write this Emoji icon in unicode in a string. Everything I have tried just shows a strange symbol instead of the icon.
Can anyone tell me, how I can put an Emoji icon into an NSString?

馃摫 You want emoji 馃槃?
馃惙馃惢馃惃馃惛 They're in Unicode now 馃惛馃惃馃惢馃惙
If you open up the 馃捇Character Viewer馃捇 you can actually paste them directly into your source code. If you'd rather, you can encode them in hexadecimal (\U0001F431 for cat face) by looking them up in the Unicode code charts (especially the chart for the U+1F300 block).
If you want to make sure they appear in color, you'll need to select the "Apple Color Emoji" font for the Emoji. You can use NSAttributedString to set the font on a per-character basis.

Related

NS button text interprets FontAwesome

If I set the text of the Button whose font is FontAwesome to something like "Download" - it interprets 'down' as an font from FA as well as 'ad'
e.g. Open = it'll display O and then a pen icon from FA.
Very weird - how can I stop this.
I'd like the button text to contain both FA icons (specified with unicode escape codes) and regular text.
I haven't used FontAwesome recently, I recall they use to denote icons by character code so there were no issues in combining text along with icons, not sure if that's changed now.
As a workaround you can use formattedText instead of text. You will be able to use different fonts within Button with 2 different FormattedString definitions, one for icon and another for text.

Interface Builder cuts off text input for long strings when using attributed text

Is this a bug or by design? The text input is cut off when text is getting long. Using Xcode 8. How can I avoid this? It stops me from inputting the text I want.
I realized that you can make the thing stop cutting off text by simply making the Xcode window and/or panel wider. I still think though that this kind of control usually should allow for scrolling within itself... I seem to remember that it did at times, but I just can't get it working now.

Sublime text 3 automatically highlights the texts when typing on mac

when i type something in sublime 3 it has a white box appear around the text, when i out focus the sublime and get focus back, the text which is highlighted disappear.
So i have to press escape or space to turn it off before saving which is super annoying. Tried to turn off some highlight functions in sublime setting but doesn't work.
please see the example image below, thanks
p/s i dont install any plugin except package control, and it happens to every language (php, js, html, text, xml ...)
i used a vietnamese keyboard, so turn it off when the problem sold.
i think it may happen to another keyboard. thanks

Has anyone heard of this strange bug with the standard Windows message box?

Years ago, I was messing around with Visual Basic and I discovered a bug with the MsgBox function. I tried searching for it, but nobody had ever said anything about it. It's not just with Visual Basic though; it's with anything that uses the standard Windows MessageBox API call.
The bug is triggered when the title text has more than one character, and the first character is a lowercase 'y' with an umlaut ('每'). What's so special about this character? It almost definitely not the character itself, but rather its ASCII value that's special. '每' is character 255 (0xFF), meaning it's the highest value that can be stored in an unsigned byte, and all its bits are set to 1.
What does this bug do? Well, there are two different possibilities, which depend on the number of characters in the title text. If there are an even number of characters (unless it's 2) in the title text, no message box appears, and you just hear the alert sound. If there are two characters in the title text, or any odd number other than 1 (in which case the bug wouldn't be triggered)...then this happens:
And that's not all--the message will also be truncated to one line. It seems like the kind of bug that would occur in at least one semi-high-profile incident, considering how often this API call is used. Are there any reports of this on the Internet, or anything showing what could cause it? Maybe it's a Unicode-related glitch, like that "bush hid the facts" glitch in Notepad?
I made a program in case you want to play around with this; download it here.
Alternatively, copy the following into Notepad, save it with a .vbs extension, and double-click it to display the dialog box seen above:
MsgBox "Windows 3.1 font, anyone?", 0, "每 ODD NUMBER!"
Or for a different font:
MsgBox "I CAN HAS CHEEZBURGER?", 0, "每 HImpact"
EDIT: It seems that if the first four characters are 每's, it doesn't ever display the message, even if there's an odd number of characters.
This is a bug with dialog templates generally. It is not a message box bug as such.
For example, in Visual Studio create the default win32 application. In the .rc file, change the caption in the template for the about box from
CAPTION "About sampleapp"
to
CAPTION "每T"
and the bug will manifest itself when you display the about box.
In the DLGTEMPLATEEX documentation note that the menu and class name have type sz_Or_Ord which means either a null-terminated string or 0xFFFF followed by a single word resource identifier.
Windows incorrectly applies a similar scheme to the dialog title: if the first character is 0xFF then it treats the title as being two WORDs long, but only when it is trying to locate the font information. When it is displaying the title it correctly treats the title as a string.
In other words, Windows is looking for the font information inside the title string. In most case this won't specify a valid font, so Windows defaults to the system font.
To prove this, I constructed a dialog template in memory (based on this). Once this was working I deleted the code that writes the font information to the template and used the dialog title "每a\xd\x200\x21SimSun". This displays the dialog in italic SimSun because windows is reading the font information from the title string.
This bug is likely a hangover from 16-bit Windows, where (I guess) 0xFF was used as the resource ID marker.
A strange bug. I suspect the symptoms are the result of the way the MessageBox() actually displays the dialog.
Internally, MessageBox() builds a dialog template dynamically. If you look at the description of a DLGTEMPLATE structure you'll find the following nugget of information:
In a standard template for a dialog box, the DLGTEMPLATE structure is
always immediately followed by three variable-length arrays that
specify the menu, class, and title for the dialog box. When the
DS_SETFONT style is specified, these arrays are also followed by a
16-bit value specifying point size and another variable-length array
specifying a typeface name.
So, the in-memory layout of a dialog template has the font specification immediately following the dialog box title.
Visual Basic does not use Unicode and so the function you're calling is actually MessageBoxA(). This is simply a thunk that converts the passed-in strings from multibyte to Unicode and then calls MessageBoxW().
I believe what's happening is that, for some reason, the conversion of that string from multibyte to Unicode is either going wrong, or returning a spurious length value. This has the knock-on effect, when the dialog template is built in memory, of corrupting the memory immediately following the title string - which, as we know, is the font specification.

How to display unicode Arabic string in VS output window?

I have a uni-code string in Arabic to display in output window rather than in console, so I could only use OutputDebugStringW, and I call SetConsoleOutputCP(1256) to set Arabic code page but still it only output "????". What should I do...
This is a documented restriction for OutputDebugStringW():
OutputDebugStringW converts the specified string based on the current system locale information and passes it to OutputDebugStringA to be displayed. As a result, some Unicode characters may not be displayed correctly.
Calling SetConsoleOutputCP() doesn't solve the problem, that changes the code page for the console window, not the debugger. You'd have to change your system locale, Control Panel + Region, Administrative tab. If Arabic is your favorite language then changing it to 1256 is the appropriate thing to do. It will of course have system-wide effects.

Resources