Fixed escaping a string with an invalid multibyte sequences

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Related tickets | #78
| License       | MIT