Right encoding support - part 02

Almost obvious patches.

@jmarshallnz thanks in advance for review!