How do you align string containing accents in nim

Viewed 52

In Nim, how do you align strings containing accented characters?

For example the following code

var maxLen = 20
var s1 = alignLeft("John le Carré", maxLen)
var s2 = alignLeft("John le Carre", maxLen)
echo s1 & ":"
echo s2 & ":"

produces the following output.

John le Carré      :
John le Carre       :

What is the correct way of getting the colons to line up?

1 Answers

You left out the most important line:

import strutils

Which you should change to:

import unicode
Related