# SDL: stdlib: Fix copy/paste error in StepUTF8().

**URL:** <https://discourse.libsdl.org/t/sdl-stdlib-fix-copy-paste-error-in-steputf8/69505>\
**Category:** SDL Commits\
**Created:** [October 8, 2026, 3:18pm UTC](https://discourse.libsdl.org/t/sdl-stdlib-fix-copy-paste-error-in-steputf8/69505 "2026-10-08T15:18:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [October 8, 2026, 3:18pm UTC](https://discourse.libsdl.org/t/sdl-stdlib-fix-copy-paste-error-in-steputf8/69505/1 "2026-10-08T15:18:03Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/57f22e6e43ad7c40912645d6cc76083107b4c367>
>
> Fixes #16464.

```diff
From 57f22e6e43ad7c40912645d6cc76083107b4c367 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 8 Oct 2026 11:10:08 -0400
Subject: [PATCH] stdlib: Fix copy/paste error in StepUTF8().

Fixes #16464.
---
 src/stdlib/SDL_string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c
index c0525ef928005..a8a36e9cd99a5 100644
--- a/src/stdlib/SDL_string.c
+++ b/src/stdlib/SDL_string.c
@@ -240,7 +240,7 @@ static Uint32 StepUTF8(const char **_str, const size_t slen)
         const Uint8 str2 = str[2];
         const Uint8 str3 = str[3];
         if (((str1 & 0xC0) == 0x80) && ((str2 & 0xC0) == 0x80) && ((str3 & 0xC0) == 0x80)) { // If trailing bytes aren't 10xxxxxx, sequence is bogus.
- const Uint32 octet2 = ((Uint32) (str1 & 0x1F)) << 12;
+ const Uint32 octet2 = ((Uint32) (str1 & 0x3F)) << 12;
             const Uint32 octet3 = ((Uint32) (str2 & 0x3F)) << 6;
             const Uint32 octet4 = ((Uint32) (str3 & 0x3F));
             const Uint32 result = ((octet & 0x07) << 18) | octet2 | octet3 | octet4;

```
