merged Foxboron's fix for bad string encoding.