Mismatch between lengths of UTF-16 and actual Unicode code points

(#4079) Bug Open: Needs triage api desktop

Reproduction steps

  1. Open any interface that restricts maximum string length.
  2. Enter any string approaching the maximum character limit, but with some SMP characters. (e.g. 𐑛𐑦𐑕𐑣𐑸𐑥𐑩𐑯𐑦 | 最不調和の伝播者 | 異議の元素, my actual display name at 28 characters)
  3. Hit "apply".

Expected behaviour

String length validation passes (28 ≤ 32).
// Please, use either, I just want this bug to be fixed and get it over with.
"use strict";
const isLengthExceeded = function (input, maxLength) {
  let actualSize = 0;
  for (const char of input) {
    actualSize ++;
  };
  return actualSize <= maxLength;
};
// Alternative method
const isLengthExceeded = function (input, maxLength) {
  return Array.from(input).length <= maxLength;
};

Actual behaviour

String length validation fails (37 > 32), both in the browser and in the API.
"use strict";
const isLengthExceeded = function (input, maxLength) {
  return input.length <= maxLength;
};

Build information

Stable Web 2026.1016.10924, Windows NT 10.0 (x64), Firefox 153.0 (Tor Browser), Locale en-GB

Platform

Web, API

Comments

Sign in with Fluxer to comment and vote.

No comments yet.