How can I write a null character on a Macbook Pro? I'd prefer to use just the keyboard or something that I can reach everywhere, without using a third-party program.

  • 2
    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 – user151019 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
  • 2
    @LatinSUD Bug exploitation, software testing, binary file editing, to name just a few. – Daniel Beck Jun 6 '11 at 13:03
  • Type null character in terminal – phuclv Nov 17 '16 at 16:52

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.

  • 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
  • 1
    @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

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

  • 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
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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