Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #152 Turn a character into a string

Create string s containing only the character c.

(def s (str c))
string s { 'c' };
string s = c.ToString();
import std.conv : to;
string s = to!string(c);
character(len=:),allocatable :: s
character(len=1) :: c
s=c
import "fmt"
s := fmt.Sprintf("%c", c)
s = [c]
let s = c
String s = String.valueOf(c);
String s = Character.toString(c);
String s = c + "";
String s = = new Character(c).toString();
(defparameter *s* (string c))
(defparameter *s* (string c))
s = c
$s = (string) $c;
var
  s: string;
begin
  s := 'c';
end.
my $s = $c;
s = c
s = ?c
let s = c.to_string();

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org