in reply to Encoding function needed

What is the intended application? Are you willing to share?