C++ Program to Determine the Unicode Code Point at a Given Index

Last Updated : 21 Aug, 2026

A Unicode code point is a unique numeric value assigned to each character in the Unicode standard.

  • Uses a loop to traverse the string and access each character.
  • For ASCII characters, their numeric value is also their Unicode code point.

Input: arr = "geEKs"

Output: 

The Unicode Code Point At 0 is = 71.
The Unicode Code Point At 1 is = 101.
The Unicode Code Point At 2 is = 69.
The Unicode Code Point At 3 is = 107.
The Unicode Code Point At 4 is = 83.

Approach

We can traverse the string using a loop and access each character using its index. Converting the character to an integer gives its numeric character value. For the ASCII characters used in this example, these values are also their Unicode code points.

C++
#include <iostream>
using namespace std;

int main()
{
    char arr[] = "GeEkS";

    cout << "Input String = " << arr << '\n';

    for (int i = 0; arr[i] != '\0'; i++) {
        int codePoint = static_cast<unsigned char>(arr[i]);

        cout << "The Unicode Code Point At "
             << i << " is = " << codePoint << '\n';
    }

    return 0;
} 

Output

Input String = GeEkS 
The Unicode Code Point At 0 is = 71
The Unicode Code Point At 1 is = 101
The Unicode Code Point At 2 is = 69
The Unicode Code Point At 3 is = 107
The Unicode Code Point At 4 is = 83

Explanation

  • arr stores the characters of the string as a null-terminated character array.
  • The loop traverses the string until it reaches '\0'.
  • arr[i] accesses the character at index i.
  • The character is converted to an integer to obtain its numeric value.
  • For ASCII characters, this numeric value is also the corresponding Unicode code point.

Note: This approach works for ASCII characters and other characters represented by a single char value. A UTF-8 string may use multiple bytes for one Unicode code point, so decoding is required to correctly find arbitrary Unicode code points.

Comment