Logo

Programming-Idioms

Write "Hello World and 你好" to standard output in UTF-8.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
  use iso_fortran_env
  integer, parameter :: ucs4  = selected_char_kind ('ISO_10646')
  character(kind=ucs4,  len=30) :: hello_world
  hello_world = ucs4_'Hello World and ' &
                // char (int (z'4F60'), ucs4)     &
                // char (int (z'597D'), ucs4)

  open (output_unit, encoding='UTF-8')
  write (*,*) trim (hello_world)
import "fmt"
fmt.Println("Hello World and 你好")
{$IFDEF WINDOWS}Windows{$ENDIF}
  {$IFDEF WINDOWS}
  SetTextCodePage(Output, CP_UTF8);
  SetConsoleOutputCP(CP_UTF8);
  {$ENDIF}
  writeln('Hello World and 你好');
use utf8;
binmode STDOUT, ':utf8';

print('Hello World and 你好');
print('Hello World and \u4f60\u597d')
print('Hello World and 你好')
puts "Hello World and 你好" 
println!("Hello World and 你好")