---
title: "League URI: UTF-8 in RFC 6570 URI templates | VulCode"
description: "In League URI we fixed the RFC 6570 prefix modifier in URI templates, which counted bytes instead of characters and split UTF-8 characters, in PHP."
url: "https://vulcode.com/en/opensource/contributions/league-uri"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

thephpleague/uri-src

# League URI

A set of PHP libraries for working with URIs and URI templates.

[See the repository](https://github.com/thephpleague/uri-src) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: PHP
- **GitHub stars**: 51
- **Merged changes**: 1
- **Project site**: [uri.thephpleague.com](https://uri.thephpleague.com)

## What we changed

The {var:N} prefix modifier in URI templates counts characters instead of bytes and no longer splits multibyte characters.

### What this work shows

- RFC 6570 URI templates

- UTF-8 and mbstring in PHP

- Percent-encoding in URLs

What was broken

### {?currency:1} cut the euro sign in half

Operator::inject() applied the prefix modifier with substr(), which counts bytes. The euro sign takes three bytes in UTF-8, so the template {?currency:1} with the value €uro gave ?currency=%E2, a fragment that is not valid UTF-8 once decoded.

How we fixed it

### The prefix counts characters

The prefix is now taken with mb_substr() and an explicit UTF-8 encoding, as section 2.4.1 of RFC 6570 requires, so the result does not depend on the application's mbstring settings. The multibyte cases from the RFC 6570 conformance suite bundled with the project now pass as well.

[#192](https://github.com/thephpleague/uri-src/pull/192)

## Merged change 1

- [#192 Fix multibyte characters being split by the URI Template prefix modifier Merged 6 September 2026](https://github.com/thephpleague/uri-src/pull/192)

## What it taught us

An RFC has to be read literally: RFC 6570 counts the prefix in characters while PHP's substr() counts bytes, so any non-ASCII character, Polish letters included, could be cut in half.

[More about this technology: PHP](https://vulcode.com/en/technologies/php)

## Other projects we write code for

- [**Composer** PHP · 29,590 stars The dependency manager for PHP: it installs and updates a project's libraries from its composer.json.](https://vulcode.com/en/opensource/contributions/composer)

- [**PHPMailer** PHP · 22,347 stars The classic PHP library for sending email, used by WordPress and many other systems.](https://vulcode.com/en/opensource/contributions/phpmailer)

- [**Monolog** PHP · 21,407 stars A PHP logging library that sends records to files, sockets, inboxes, databases and web services. Symfony and Laravel use it, among others.](https://vulcode.com/en/opensource/contributions/monolog)

- [**Carbon** PHP · 16,583 stars A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.](https://vulcode.com/en/opensource/contributions/carbon)

- [**Whoops** PHP · 13,231 stars A PHP library that turns uncaught exceptions into a readable error page with the stack trace, known from Laravel.](https://vulcode.com/en/opensource/contributions/whoops)

- [**ramsey/uuid** PHP · 12,642 stars A PHP library for generating universally unique identifiers (UUIDs).](https://vulcode.com/en/opensource/contributions/ramsey-uuid)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
