fixing invalid UTF8 replacament for php 5.4, 5.5

Closes #1053