Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can i write a null character on a macbook pro? Preferably using just the keyboard or something that i can reach everywhere, without using a 3rd party program.

share|improve this question
Most application will not read this properly so I think it would help if you could say how you want to use this. e.g. terminal can use this in one way but GUI apps will differ –  Mark Jun 5 '11 at 20:30
Please uncheck my answer so I can delete it. –  KCotreau Jun 6 '11 at 11:28
Why would any user on any OS want to input the null character ??? –  LatinSuD Jun 6 '11 at 12:50
@LatinSUD Bug exploitation, software testing, binary file editing, to name just a few. –  Daniel Beck Jun 6 '11 at 13:03
add comment

2 Answers

up vote 6 down vote accepted

You can do this with the Unicode Hex Input method (enable it in System Preferences -> Language & Text pane -> Input Sources tab, then select it from the menu item) by holding Option and typing "0000".

Warning: the null character is not allowed in C-language strings (it's used to indicate the end of the string), so not all programs will cope with it. In TextEdit, for example, you can insert a null into a document, but when you save the document it'll only save the part before the null.

share|improve this answer
Can't find that setting, maybe it's because i don't have numpad? alt+numbers just writes special chars as usual. your warning: That's exactly what i am gonna use it for. Buffer overflowing and null-injecting my own programs. –  Filip Haglund Jun 6 '11 at 8:19
@Filip Haglund: which setting can't you find, the setting in System Preferences or the menu item? Also, which version of Mac OS X (and language), as I think they got moved around between versions. –  Gordon Davisson Jun 6 '11 at 15:31
davisson Got it. Didn't take it far enough in my head to translate it before searching for it. Can't get it to write null in terminal though... It did type it in safari search-box tho :) google missed half my search and url shows %00 :D –  Filip Haglund Jun 6 '11 at 20:33
@Filip Haglund: Good; I'll skip the screenshots I was working on (since I don't know Swedish at all, getting them was a little fun...) BTW, null seems to work OK as far as Terminal itself is concerned, but (for example) bash won't let me include it directly in a command line. If you type it into xxd's stdin, though, it shows a null byte just as expected. –  Gordon Davisson Jun 6 '11 at 20:58
sure does :) tnx –  Filip Haglund Jun 7 '11 at 14:26
add comment

Depends on your terminal, in Terminal.app and Iterm2 you can use ^@ (Ctrl+Shift+2). See here.

share|improve this answer
I'm not talking about just terminal. Also, i can't get it to work. Do you have an example where it doesn't give me a beep error? –  Filip Haglund Jun 5 '11 at 19:44
@Filip I have no idea what application you are trying to use, so no I don't. Maybe you should rework your question and include more detail. Perhaps there is even another way to accomplish whatever you are after. –  zeekay Jun 5 '11 at 20:19
i tried it in terminal, with a beep-error as a result. I would like a general way to be able to write it, just like i can write other chars in windows using alt-combinations. I am using the swedish version of mac os x if that matters. –  Filip Haglund Jun 5 '11 at 20:34
@Filip I'm not sure why that would matter? Works fine with Terminal.app and Iterm2 by default, from what I can tell. –  zeekay Jun 5 '11 at 22:54
It doesn't work in terminal.app, from what i can tell :/ I think the swedish keyboard layout is messing with me. –  Filip Haglund Jun 6 '11 at 8:33
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.