Forum Bugs

Regexps don't work as expected with multi-byte characters

Apparently, strings containing multi-byte characters are not treated correctly by regexps.
The test-file below performs an identity replace on some strings and demonstrates the problem. It works as expected in a browser, but fails in Prince.

Best regards,

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">

<html xmlns="">
		<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
		<title>Regexp Multi-byte Character Bug</title>
	<style type="text/css">
	* {
		text-align: left;
	table {
		width: 100%;
		border-collapse: collapse;
	td {
		width: 30%;
	tr.ok td:last-child {
		background: green;
		width: 10%;
	} td:last-child {
		background: red;
		<h1>Regexp Multi-byte Character Bug</h1>

<tbody id="tests">

<script type="text/javascript">/*<![CDATA[*/
(function() {
	var createElement = function(name, attributes, content) {
		var attr, el;
		el = document.createElementNS('', name);
		if (attributes) {
			for (attr in attributes) {
				el.setAttribute(attr, attributes[attr]);
		if (content) {
		return el;

	var addTestResult = function(text, expected, actual) {
		var row, status;
		status = (expected === actual) ? 'ok' : 'fail';
		row = createElement('tr', { 'class': status });
		row.appendChild(createElement('td', null, text));
		row.appendChild(createElement('td', null, expected));
		row.appendChild(createElement('td', null, actual));
		row.appendChild(createElement('td', null, status));
		console.log([ text, expected, actual, status ].join('\t'));

	i, text, expected, actual,

	texts = [
		'"æøå" "x"',
		'"xyz" "x"',

	for (i = 0; i < texts.length; i++) {
		text = texts[i];
		expected = text;
		// Identity replace
		actual = text.replace(new RegExp('.', 'g'), '$&');
		addTestResult(text, expected, actual);

Thanks for the detailed test document! These issues will be fixed in Prince 8.1.
mikeday wrote:
Thanks for the detailed test document! These issues will be fixed in Prince 8.1.


Any news on when we will see a (preview/beta) release of Prince 8.1?
Soon, there are only a couple of things left to do. Please email me ( if you are interested in trying a build now.