Fixing Ill‐Formed UTF ‐16 Strings With SIMD Instructions

Read full text
Authors: Robert Clausecker, Daniel Lemire
Cited by: 0

Abstract

ABSTRACT Background We must fix ill‐formed UTF‐16 strings, where surrogate pairs are mismatched. Programming languages such as JavaScript provide functions that replace mismatched surrogates with the Unicode replacement character (U + FFFD). Objectives We seek to accelerate the correction of ill‐formed UTF‐16 strings. Methods We propose using Single Instruction, Multiple Data (SIMD) instructions to handle multiple code units in parallel, enabling faster and more efficient execution. We provide implementations for ARM NEON and x64 (SSE, AVX2, AVX‐512). Results Our implementations reach 18.9 GB/s on an Apple M4 processor and 7.5 GB/s on an Intel Ice Lake processor—up to nine times faster than the scalar baseline of the V8 JavaScript engine—while requiring as little as 0.4 instructions per byte. Integrated into Node.js, our functions make the toWellFormed JavaScript function about five times faster. Conclusions Our algorithm achieves significant performance improvements over conventional methods. Our software is part of the Google JavaScript engine (V8) and thus part of several major Web browsers.

Fields of Study & Subjects

Advanced Wireless Communication Techniques Advanced Data Compression Techniques Coding theory and cryptography

Publication details

Journal / source
Software Practice and Experience
Publication date
25 August 2026
Language
EN