Iterate through all the items in `msg` and determine whether they are strings. If they are strings then use force_encoding to change their encoding to match the internal encoding used. This will fix the broken dictionary search when string encodings mismatch between the stored key and the key being queried for.