Logo

Programming-Idioms

Assign to c the value of the i-th character of the string s.

Make sure to properly handle multi-byte characters. i is the character index, which may not be equal to the byte index.
Implementation
Go

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another Go 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
char c = s.charAt(i);
c = s[i]
c = s[i]
LazUtf8
c := Utf8Copy(s,i,1);
 c = s(i:i)
c := s[i];
let c = s.chars().nth(i).expect("s is too short");
use utf8;
$c = substr $s, $i, 1;