`<?xml encoding    encoding = 'UTF-8' ?>`
without `pos--;` position will point to first 'e' of second 'encoding' then `pos = xmlDecl.find_first_of(whiteSpaceChars, pos);` will skip second 'encoding'