Hi,
I have an idea of how to solve this problem, but wanted to check if
there is a better way. I have a base64-encoded []byte that contains a
UTF-16-BE string. Base64 part is easy, but what is the best way of
converting UTF-16-BE to UTF-8 and returning that result as []byte?
My current idea is below, let me know if I can make any improvements
in performance or code simplicity. It would be good if there was a way
of going directly from []rune to []byte without the intermediate
string step, but I couldn't find any existing functions that would do
this. There is a bytes.Runes function that does the reverse.
http://play.golang.org/p/jQc6QF5pfo
- Max