make pgsql error code parsing locale-independent

Original code results in $code being filled with wrong characters when database is running in non-english locale. For example, with russian locale $code would be "KA:" (from "ОШИБКА: ...", also note that it's not mb_substr, so it actually skips 4 characters here).