# What character encoding do cache strings use?

**URL:** <https://discourse.cmake.org/t/what-character-encoding-do-cache-strings-use/13492>\
**Category:** Code\
**Created:** [January 26, 2025, 2:58pm UTC](https://discourse.cmake.org/t/what-character-encoding-do-cache-strings-use/13492 "2025-01-26T14:58:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonYundt](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jasonyundt/32/5237_2.png) [@JasonYundt](https://discourse.cmake.org/u/JasonYundt)\
**Post date:** [January 26, 2025, 2:58pm UTC](https://discourse.cmake.org/t/what-character-encoding-do-cache-strings-use/13492/1 "2025-01-26T14:58:01Z")

</div>

I noticed that [the documentation for `string(SUBSTRING…)`](https://cmake.org/cmake/help/latest/command/string.html#substring) says this:

> Both `<begin>` and `<length>` are counted in bytes, so care must be exercised if `<string>` could contain multi-byte characters.

This got me thinking: what character encoding do strings in the CMake Language use? I suppose that you could use [`file(READ…)`](https://cmake.org/cmake/help/latest/command/file.html#read) to create strings with any character encoding, but I’m more thinking about code like this:

```auto
cmake_minimum_required(VERSION 3.30.5)
project(example_project)

set(EXAMPLE_VARIABLE "café" CACHE STRING "Example cache variable")

```

In that example, what character encoding will `EXAMPLE_VARIABLE` use? Is there any way to ensure that it will use UTF-8?
