Fix UTF-8 handling for shared queries

Signed-off-by: Kevin Murphy <murphyke@email.chop.edu>
Above and beyond.