Handle unicode literals properly in matrices

Fixes #7604

Add test.  Has to be in doctest because otherwise we'd need
the from __future__ line at the top of the test file.