How can I type the unicode character U+200B (zero-width space character) with my keyboard?
-
3Which operating system are you using? – Kurt Pfeifle Jun 25 '10 at 12:25
-
1@pipitas: If it's OS dependent, I'd prefer Windows. – Mehper C. Palavuzlar Jun 25 '10 at 14:44
-
1Side question: Why do you want a zero-width space? It doesn't help for the broken comment formatting, you'd have to use a hair space, then. – Joey Jun 26 '10 at 07:50
-
@Johannes: Because I couldn't find an answer to my question on Meta: http://meta.stackexchange.com/questions/54990/how-to-write-comments-less-than-15-characters and http://meta.stackexchange.com/questions/54990/how-to-write-comments-less-than-15-characters. Could you please explain how I can use a hair space? – Mehper C. Palavuzlar Jun 26 '10 at 08:23
-
Ah, ok, different problem then. I thought you were trying something like http://meta.stackexchange.com/questions/45424 this where ZWS doesn't work (see my test comments below the question). Also you posted the same link twice. – Joey Jun 26 '10 at 13:56
-
Oops, the second link was supposed to be http://meta.stackexchange.com/questions/10519/comments-questions-and-answers-dont-trim-unicode-u200b-when-counting-characters. – Mehper C. Palavuzlar Jun 26 '10 at 14:09
9 Answers
When using recent versions of Chrome/Chromium, you can use its console to copy the character to clipboard:
copy("\u200B") // works for BMP characters only (U+0000 to U+FFFF)
copy("\u{200B}") // works for all characters (U+0000 to U+10FFFF)
copy(String.fromCodePoint(0x200B))
- 391
- 3
- 5
First convert the hex 200B to decimal 8203
Second, making sure numlock is turned on, press the following keystrokes while holding down the Alt key, then striking the four digits on the numeric keypad, and finally releasing the Alt key.
Alt+8203
It will insert the proper character, but you may see garbage depending on the font you are using (does it contain a glyph for that character) as well as the editor you are using may not be unicode aware and treat it as two characters or something else completely.
Note: I tested this with the Arial Unicode MS font, and it worked like a champ.
- 6,511
- 4
- 37
- 48
-
1Thanks for your answer but how can I do it, for example, inside this very comment box? – Mehper C. Palavuzlar Jun 25 '10 at 17:24
-
@Mehper superuser and the stackoverflow sites use the plain "Arial" font by default, which does not contain a glyph for zero-width character. You can insert it all you want, or even copy and paste it from MS Word, and it won't work as expected on this site. To get it to work 100% correctly, they would need to specify a font that contains the correct glyph in the stylesheet - and possibly tweak the HTTP headers and embed unicode information in the HEAD element. – Goyuix Jun 25 '10 at 18:51
-
16This inserts U+2642 here. In RichEdit it works (as does using `08203`). As to the why for U+2642: 8203 mod 256 is 11 which was, in the OEM charset, the character code of the glyph ♂ (which is now U+2642). This is consistent with what I have previously observed: Using Alt+foo treats the code differently, depending on what is prefixed. If no `0` is at the start of the code, then it is interpreted in the OEM charset, otherwise the system legacy charset. In both cases Unicode is only involved in converting the result to a character. – Joey Jun 26 '10 at 08:06
-
1Obviously this differs between applications and controls, but not in a meaningful and predictable way so as a general solution this isn't quite right, still. – Joey Jun 26 '10 at 08:06
-
1By the way, browsers should have no problem picking a font for a particular glyph that isn't present in the font specified. Also Arial *does* contain a glyph for U+200B. In any case, you shouldn't see null glyphs (boxes or U+FFFD) on a semi-recent system. – Joey Jun 26 '10 at 08:09
-
3How do you type this character on a device that doesn't have a numeric pad, like some laptops? – Borek Bernard Jan 08 '12 at 09:30
-
@Borek, most laptops will allow you to do this through their function key (in combination with the alt key) – Hanna Feb 02 '15 at 23:31
Follow the instructions in Wikipedia. Unfortunately you need to set a registry key first.
After that formality is taken care of, just hold Alt and press + 2 0 0 B, typing the + and numbers on the numpad, and the letters normally.
- 2,317
- 4
- 21
- 27
-
4Typing the letter B at the end on my Windows XP terminal seems to abort the escape sequence and no character is actually sent to the text box. – Goyuix Jun 25 '10 at 15:24
-
@Goyuix: The console windows are an entirely different beast ... most of the time you can't enter characters with Alt+foo there. – Joey Jun 26 '10 at 07:49
Alt + 0129
This inserts a zero-width character.
- 803
- 1
- 11
- 17
-
11`0129` - hex 0x81 - is _not_ the same as U+200B and is _not_ a zero-width character. In the Windows Cp1252 character encoding and ISO-8859-1 it is "not a character" — there is nothing at the code-point x81, so yes, it renders as nothing, but it isn't a _word boundary_ so it's not the same as a zero-width space. In Unicode, codepoint 0x81 is in the "C1" reserved control character range. If you're using Unicode / UTF-8 encoding you should avoid characters in the range 0x80 to 0x9f (128-159). Even in Latin-1 [this range is reserved](http://cs.stanford.edu/people/miles/iso8859.html#ASCII-EXTENDED) – Stephen P Aug 19 '15 at 18:59
My go-to site for any special characters that I cannot enter via Unicode hexadecimal + Alt+X (such as in LibreOffice or Word, is Amp-what.com. You can search by character name(s), decimal, hex and even html entities. Click the desired character, a supersized box pops up and you can then click whichever part you need.
This selection box is especially useful when copying characters that you cannot easily select with your mouse, such as non-space characters or diacriticals. Simply clicking inside the box copies whichever character is there to your clipboard.
- 159
- 11
To type this on a laptop with no separate number pad, you'll need to turn numlock on, which will differ depending on your computer's manufacturer. The numbers 0-9 are then MJKLUIO789, respectively. On most laptops, these keys are marked as such. But, even if they aren't, it should still work.
- 1,677
- 14
- 18
Im not 100% sure but i think it may be Alt+127
- 620
- 1
- 8
- 17
-
hmm well the inly other one i can think if is the unicode version witch us 200 or 200B so try ALT+200 or ALT+200B – RobertPitt Jun 25 '10 at 11:41
-
1
-
-
1This answer is incorrect - ASCII 127 is commonly the DEL character, not a zero width space unicode character. – Goyuix Jun 25 '10 at 15:23
-
@RobertPitt: if you want to use the "alt+NMO" method with numeric keypad, the "NMO" part must not be the identical string as the Unicode codepoint description. Unicode codepoints are given as ***hex*** values. The "alt+NMO" method needs ***decimal*** values. You MUST convert the Unicode "NMOP" into a decimal. Then use "alt+
" on your numeric keypad. (Doesn't work for me with the examples Mehper had given, I don't have fonts. But works for all cases of "normal" characters, as well as characters which are displayed by my local charmap.exe.) – Kurt Pfeifle Jun 25 '10 at 22:24