Use charAt rather than string index

Older versions of IE do not support [] access to string contents so charAt must be used.

Fixes #677