Null character

Null character

Output a null character to stdout

See https://en.wikipedia.org/wiki/Null_character

Implementations

Bash

null_char.sh
printf "Hello World \0"

Running the program

$ bash null_char.sh 
Hello World 

C#

NullChar.cs
class NullChar
{
  public static void Main(string[] args)
  {
    Console.WriteLine("Hello World \0");
  }
}

Running the program

$ dotnet run null_char 
Hello World 

Go

null_char.go
package main

import "fmt"

func main() {
	fmt.Println("Hello World \x00")
}

Running the program

$ go run null_char.go 
Hello World 

Java

NullChar.java
public class NullChar {
  public static void main(String[] args) {
    System.out.println("Hello World \0");
  }
}

Running the program

$ java NullChar.java 
Hello World 

Javascript (Deno)

null_char.mjs
console.log("Hello World \0")

Running the program

$ deno run --allow-read --allow-write null_char.mjs 
Hello World 

Javascript (Node.js)

null_char.mjs
console.log("Hello World \0")

Running the program

$ node null_char.mjs 
Hello World 

Lua

null_char.lua
print("Hello World \0")

Running the program

$ lua null_char.lua 
Hello World 

PHP

null_char.php
<?php

echo "Hello World \0";

Running the program

$ php null_char.php 
Hello World 

Perl

null_char.pl
use strict;
use warnings;

print "Hello World \0";

Running the program

$ perl null_char.pl 
Hello World 

Python

null_char.py
print("Hello World \0")

Running the program

$ python null_char.py 
Hello World 

R

Strings in R cannot contain null characters (even though null characters are valid in UTF-8).


Raku

TM
null_char.raku
use v6;

say "Hello World \0";

Running the program

$ raku null_char.raku 
Hello World 

Ruby

null_char.rb
puts "Hello World \0"

Running the program

$ ruby null_char.rb 
Hello World 

Rust

null_char.rs
fn main() {
    println!("Hello World \0");
}

Running the program

$ cargo script null_char.rs 
Hello World 

Swift

null_char.swift
print("Hello World \0")

Running the program

$ swift null_char.swift 
Hello World