This code behaves differently in Node.js 22 and Node.js 24.
In Node.js 24, the non-breaking space (the two-byte character 0xC2A0) is replaced with a single byte 0xA0
import express from 'ultimate-express';
const str = 'Text with non break spaceses';
console.log('nodejs', process.version, Buffer.from(str, 'utf-8').toString('hex'));
const app = express();
app.get('/', (req, res) => {
res.statusCode = 200;
res.send(str);
})
app.listen(3000, () => {
console.log('Server is running on port 3000');
});
Nodejs 24
> node index.js
nodejs v24.14.0 54657874c2a077697468c2a06e6f6ec2a0627265616bc2a07370616365736573
Server is running on port 3000
> curl http://localhost:3000/ | xxd
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 28 100 28 0 0 10574 0 --:--:-- --:--:-- --:--:-- 14000
00000000: 5465 7874 a077 6974 68a0 6e6f 6ea0 6272 Text.with.non.br
00000010: 6561 6ba0 7370 6163 6573 6573 eak.spaceses
Nodejs 22
> node index.js
nodejs v22.16.0 54657874c2a077697468c2a06e6f6ec2a0627265616bc2a07370616365736573
Server is running on port 3000
> curl http://localhost:3000/ | xxd
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 32 100 32 0 0 6064 0 --:--:-- --:--:-- --:--:-- 6400
00000000: 5465 7874 c2a0 7769 7468 c2a0 6e6f 6ec2 Text..with..non.
00000010: a062 7265 616b c2a0 7370 6163 6573 6573 .break..spaceses
This code behaves differently in Node.js 22 and Node.js 24.
In Node.js 24, the non-breaking space (the two-byte character 0xC2A0) is replaced with a single byte 0xA0
Nodejs 24
Nodejs 22