Fixed in [77a7d8d123] (core-8-5-branch). In trunk, the fix was already applied more than 5 years ago ([ee4709ceaf], thanks to dkf), so I just backported dkf's fix.

Explanation:  The "encoding convertfrom" command creates an internal byte array representation from the string, and "string range" tries to make smart use of the byte array representation. But that shortcut was simply wrong.